Angular 6 ServiceWorker

编程入门 行业动态 更新时间:2024-10-24 20:12:40
本文介绍了Angular 6 ServiceWorker - index.html 返回响应 404 Not Found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在我的测试服务器上部署了 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

本文发布于:2023-11-16 15:06:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Angular   ServiceWorker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!