文章内容
2020/5/25 11:04:47,作 者: 黄兵
Could not subscribe to notifications Error: Service workers are disabled or not supported by this browser
最近在Angular中需要使用notification推送服务,按照这篇文章操作:Angular Push Notifications: a Complete Step-by-Step Guide,在点击订阅的时候出现了如下错误:
Could not subscribe to notifications Error: Service workers are disabled or not supported by this browser
出现问题的原因:
Because ng serve does not work with service workers, you must use a separate HTTP server to test your project locally. You can use any HTTP server
由于ng serve不适用于service workers,因此您必须使用单独的HTTP服务器在本地测试您的项目。您可以使用任何HTTP服务器
解决方案:
安装http-server,具体命令如下:
npm install --global http-server
之后运行:
http-server -p 8080 -c-1 dist/project-name
这里需要生成项目。
参考资料:
3、Angular Push Notifications: a Complete Step-by-Step Guide
4、Angular 6 - “Service workers are disabled or not supported” error
评论列表