我已经在我的测试服务器上部署了 PWA www.mytestserver.me/dev/pwa/ 在dev/pwa"文件夹下.该应用程序以 100% 的 PWA 分数通过了 Lighthouse.但是该应用程序仍然无法按预期运行.它根本不起作用.)) JS 控制台说:
I've deployed PWA on my test server wwww.mytestserver.me/dev/pwa/ under 'dev/pwa' folder. The app passed Lighthouse with 100% PWA score. But the app still doesn't work as it's expected. It just doesn't work at all. )) JS console says:
无法加载'www.mytestserver.me/dev/pwa'.服务工作者向 FetchEvent.respondWith() 传递了一个被拒绝的承诺'错误:响应不正确(fetchAndCacheOnce):请求www.mytestserver.me/index.html 返回响应 404 不找到'-ngsw-worker.js:589:31
Failed to load ‘wwww.mytestserver.me/dev/pwa’. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with ‘Error: Response not Ok (fetchAndCacheOnce): request for wwww.mytestserver.me/index.html returned response 404 Not Found’ - ngsw-worker.js:589:31
在我的 manifest.json 中,我有:scope":/"和start_url":/".我试图将它们设置为 www.mytestserver.me/dev/pwa/ 和只是/dev/pwa/但结果是一样的.
In my manifest.json I have: "scope": "/" and "start_url": "/". I tried to set them to wwww.mytestserver.me/dev/pwa/ and to just /dev/pwa/ but result is the same.
推荐答案您只需要更改 ngsw-config.json 中的 index 属性从 /index.html 到 /dev/pwa/index.html.
You just need to change index property in your ngsw-config.json from /index.html to /dev/pwa/index.html.
如果这不起作用,您需要清理浏览器缓存.至于我,它只有在完全清除浏览器数据后才开始工作.
If this doesn't work, you need to clean browser caches. As for me it started to work only after complete clearing of browser data.
更多推荐
Angular 6 ServiceWorker
发布评论