Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Add support for --base-href #143

Open
marcalj opened this issue Apr 24, 2017 · 7 comments
Open

Add support for --base-href #143

marcalj opened this issue Apr 24, 2017 · 7 comments

Comments

@marcalj
Copy link

marcalj commented Apr 24, 2017

I'm using --base-href /n-angular4/ to build but it doesn't generate the correct paths in the ngsw-manifest.json file in dist folder.

ngsw-manifest.json

{
    "routing": {
        "index": "/index.html",
        "routes": {
            "/": {
                "prefix": false
            }
        }
    }
}

After manually setting the new paths and clearing the Service Worker it's finally working.

@marcalj
Copy link
Author

marcalj commented Apr 24, 2017

Note that it should be registered with a scope:
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register

navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/n-angular4/'})

NOTE: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers

@marcalj
Copy link
Author

marcalj commented Apr 24, 2017

In Chrome Canary I'm getting this error:

Console: {"lineNumber":0,"message":"The FetchEvent for \"https://love.com/n-angular4/#!/auth/login\" resulted in a network error response: the promise was rejected.","message_level":2,"sourceIdentifier":1,"sourceURL":""}
Console: {"lineNumber":0,"message":"Uncaught (in promise) TypeError: Failed to fetch","message_level":3,"sourceIdentifier":1,"sourceURL":"https://love.com/n-angular4/worker-basic.min.js"}

@marcalj
Copy link
Author

marcalj commented Apr 24, 2017

I'm totally lost, I've been able to make it work in Chrome, but with a new version, when going offline it doesn't work now :/

@marcalj
Copy link
Author

marcalj commented Apr 24, 2017

In Firefox it seems that file ngsw-manifest.json is not cached (is not declared in static.urls and Firefox shows an corrupted error warning when offline because it cannot load it.

@webmaxru
Copy link
Member

Firefox has some strange behaviour for respondWith() method. Could you confirm the Failed to load .... A ServiceWorker passed a redirected Response to FetchEvent.respondWith() while RedirectMode is not ‘follow’. error in DevTools?

@webmaxru
Copy link
Member

webmaxru commented Apr 24, 2017

This change should fix Corrupted Content Error in Firefox: https://github.com/GoogleChrome/sw-precache/pull/233/files - it was only the beginning of the discussion. The actual fix is: GoogleChromeLabs/sw-precache#241

More context: GoogleChromeLabs/sw-precache#220
Technical background: https://bugs.chromium.org/p/chromium/issues/detail?id=669363&desc=2#c1

@alxhub, please have a look

@marcalj
Copy link
Author

marcalj commented Apr 25, 2017

In Chrome Canary I can inspect the first fetch:
sw

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants