angularmanifestservice-workerangular-service-workerangular-pwa

Angular service worker doesn't work in sub directory


I have created a new angular project and added @angular/pwa, I can't figure out how to get the service worker to work when the website is in a directory. I tried adding the folder to every link in ngsw-config.json and adding a dot before the links (which worked to make the angular app to run in a folder by using <base href="./">).

Editing the staturl in manifest.webmanifest to "start_url": "/folder/" made the app installable in chrome but it is still not available offline (HTTP ERROR 504).

Versions: Angular CLI: 8.3.8 Node: 10.16.3 @angular/pwa: 0.803.8


Solution

  • Here is a solution: https://github.com/angular/angular/issues/25055#issuecomment-408073162 I had to replace ngsw-worker.js