我已经在我的测试服务器上部署了 PWA https://wwww.mytestserver.me/dev/pwa/在“dev/pwa”文件夹下。该应用程序以 100% 的 PWA 分数通过了 Lighthouse。但是该应用程序仍然无法按预期运行。它根本不起作用。 )) JS 控制台说:
Failed to load ‘https://wwww.mytestserver.me/dev/pwa’. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with ‘Error: Response not Ok (fetchAndCacheOnce): request for https://wwww.mytestserver.me/index.html returned response 404 Not Found’ - ngsw-worker.js:589:31
在我的 manifest.json 中,我有:“scope”:“/”和“start_url”:“/”。我试图将它们设置为 https://wwww.mytestserver.me/dev/pwa/和只是/dev/pwa/但结果是一样的。
最佳答案
您只需要将 ngsw-config.json 中的 index 属性从 /index.html 更改为 /dev/pwa/index.html.
如果这不起作用,您需要清理浏览器缓存。对于我来说,它只有在完全清除浏览器数据后才开始工作。
关于Angular 6 ServiceWorker - index.html 返回响应 404 Not Found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53170498/