在Tomcat Apache生产服务器中部署Angular 7 PWA应用程序

问题描述:

我已经创建了一个Angular PWA应用程序,并通过运行以下代码来构建它: ng build --prod .

I've created an Angular PWA application and built it by running: ng build --prod.

它已成功构建了可用于生产的应用程序.
我已经通过运行以下命令在本地运行了构建的应用程序: http-server -o ,它已按预期运行.

It has built the production ready application successfully.
I've ran the built application in local by running command: http-server -o, It was running as expected.

问题:
当我在生产服务器的tomcat apache webapp目录中部署并运行它时,我得到: Service worker未注册或无法控制起始URL .

服务人员未在我的生产环境中注册.

Service worker is not registering in my production environment.

请帮助我,谢谢

您需要具有HTTPS连接才能注册服务工作者.但是它仍然可以在没有HTTPS的本地主机上工作.

You need to have HTTPS connection to register a service worker. But still it works on localhost without HTTPS.

https://developers.google.com/web/基础知识/入门/服务工作者/#you_need_https