Angular 6 @angular/pwa - sw does not successfuly serve the manifest's start_url

点点圈 提交于 2019-12-23 13:07:37

问题


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

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

  • Using absolute links
  • Making sure the start_url is within the SW's scope (sw is in the main folder)
  • Using the filename "/index.html" as I've seen in other support threads here.
  • Clearing all browser history and cache everytime.
  • Searching through Github issues on the @angular/pwa package
  • Searching google in general for this PWA issue.

Here's my manifest:

{
  "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/**"

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.

Have no idea what I'm missing on this one.


回答1:


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

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

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

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

I have yet to optimize performance though.



来源:https://stackoverflow.com/questions/52535993/angular-6-angular-pwa-sw-does-not-successfuly-serve-the-manifests-start-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!