GoogleChromeLabs / web-push-codelab

Other
556 stars 291 forks source link

multiple site #38

Closed ofirk11 closed 7 years ago

ofirk11 commented 7 years ago

Hello i want to put script in a lot of my website, but in all the web site in to register to the serviceWorker , when i try to do it from the script is says me that there is problem because the origin url . what can i do to fix it , but i dont want to upload every site the file

gauntface commented 7 years ago

service workers are restricted to origin (i.e. the serrvice worker file MUST be loaded on to the website trying to use it).

Best thing you can do is upload a service worker to everything site which then uses importScripts() to pull in a script from a different origin.

BUT - if you do this, you MUST revision the file in the importScript to ensure that the latest file shared by all service workers is updated when a new version is published - this will mean uploading a new service worker to every site.