Angular 6 @angular/pwa - sw 无法成功提供清单的 start_url [英] Angular 6 @angular/pwa - sw does not successfuly serve the manifest's start_url

查看:25
本文介绍了Angular 6 @angular/pwa - sw 无法成功提供清单的 start_url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 angular 6 和 @angular/pwa 包构建了一个 PWA.

I've built a PWA using angular 6 and the @angular/pwa package.

我一直在尝试解决这个问题,但无论我做什么,我都会收到 start_url 错误.我试过了:

I've been trying to fix this but no matter what I do, I'm getting the start_url error. I have tried:

  • 使用绝对链接
  • 确保 start_url 在 SW 的范围内(sw 在主文件夹中)
  • 使用我在其他支持线程中看到的文件名/index.html".
  • 每次都清除所有浏览器历史记录和缓存.
  • 在@angular/pwa 包上搜索 Github 问题
  • 一般在谷歌搜索这个 PWA 问题.

这是我的清单:

{
  "name": "BC Doc View",
  "short_name": "BCview",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",

在这段代码之后,只有一堆图标,与这篇文章无关.

After this piece of code there's just a bunch of icons, irrelevant to this post.

我对服务工作者的配置:

My configuration for the service worker:

{
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "BC Doc View",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**"

我使用 ng build --prod 命令实际生成的 Service Worker 有 2200 行代码,所以我认为将其发布在这里没有意义.

My actual produced service worker using the ng build --prod command is 2200 lines of code so I don't think it would be relevant to post that here.

不知道我错过了什么.

推荐答案

我已经为这个错误哭了 3 小时,在我在这里发布后几分钟我找到了解决方案.

I've cried with this error for 3 hours, minutes after I post it here I found the solution.

我一直在将其测试到开发子域中并像访问 subdomain.domain.com/folder 一样访问它

I've been testing this into a dev subdomain and accessing it like subdomain.domain.com/folder

将所有内容放入主文件夹后,我的 PWA 得分为 100.

Once I've put everything in the main folder I'm getting a 100 PWA score.

https://i.imgur.com/ex3Os87.png

我还没有优化性能.

这篇关于Angular 6 @angular/pwa - sw 无法成功提供清单的 start_url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆