Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 - no manifest was fetched

I'm trying to use a Service worker in my app.

I've added @angular/pwa, registered the service worker:

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('/ngsw-worker.js', {
        scope: '/'
    }).then((registration) => {
        console.log("Service worker OK!")
    });
}

When i run Google Lighthouse on my local everything work perfect, and the site works in online mode, but whednI upload my app to server I recive an error in Lighthouse:

No manifest was fetched.

Do I use a wrong path?

manifest.json:
"start_url": "/index.html",
like image 679
Jakub Matwiejew Avatar asked Dec 13 '22 16:12

Jakub Matwiejew


2 Answers

After adding the @angular/pwa, double check these:

1.In your angular.json file, under assets, add the manifest.json, like below

        "assets": [
          "src/favicon.ico",
          "src/assets",
          "src/manifest.json"
        ],

2.Your manifest.json file should be in the src/ directory, so src/manifest.json

3 Then in your ngsw-config.json file, you should have this:

  "files": [
    "/favicon.ico",
    "/index.html",
    "/manifest.json"
  ],

Do the three steps above, and you're good to go.

like image 159
KhoPhi Avatar answered Dec 16 '22 04:12

KhoPhi


That error means that your index.html file doesn't tell browsers about the manifest. Add:

<link rel="manifest" href="manifest.json">
like image 37
abraham Avatar answered Dec 16 '22 05:12

abraham