Parcourir la source

fix(pwa) fix loading the service worker

We typically use a base URL for static assets using a CDN so loading the worker
from there won't work since it's a different origin. Using a URL relative to the
origin of the page will make it be loaded from the right place.
master
Saúl Ibarra Corretgé il y a 4 ans
Parent
révision
d5b2da02c1
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2
    2
      index.html

+ 2
- 2
index.html Voir le fichier

@@ -25,7 +25,7 @@
25 25
 
26 26
             if (shouldRegisterWorker) {
27 27
                 navigator.serviceWorker
28
-                    .register('pwa-worker.js')
28
+                    .register('/pwa-worker.js')
29 29
                     .then(reg => {
30 30
                         console.log('Service worker registered.', reg);
31 31
                     })
@@ -33,7 +33,7 @@
33 33
                         console.log(err);
34 34
                     });
35 35
             }
36
-        })
36
+        });
37 37
     </script>
38 38
     <script>
39 39
         // IE11 and earlier can be identified via their user agent and be

Chargement…
Annuler
Enregistrer