Service Worker In Subdirectory, But I Want Scope To Be Root
I am having service worker js in subdirectory (/data/system/) but I want it's scope to be from root directory. Following code: if ('serviceWorker' in navigator) { navigat
Solution 1:
So, the answer is rather complex.
First, I noticed, that the code I provided earlier was registering service worker 2 times - first it was searching for root service worker, and second for the directory I specified. Problem lies in firebase itself, because it strictly search for root service worker. So I had to download firebase.js and re-work it so it search for my directory only. (for anyone curious in build 3.6.1-rc.3, line 525 in "navigator.serviceWorker.register" just change URL to yours desired) And use local copy of firebase instead of official one.
Second, I had to add .htaccess to the directory service worker is in with the following lines:
<Files "firebase-messaging-sw.js">
Header set Service-Worker-allowed "/"
</Files>
Just leaving this here for anyone else searching the same thing.
Post a Comment for "Service Worker In Subdirectory, But I Want Scope To Be Root"