In case of our development, we serve files from https://localhost as the app is hosted in salesforce.com. In chrome service worker on chrome blocks anything coming from self-signed server i.e (https://localhost).
So is there a way to disable/unregister service workers when in development mode. Any pattern to follow for this.
Thanks
In Chrome there is no built-in flag to disable service workers specifically. But service workers count as "cookies/site data" at chrome://settings/cookies so blocking those disables service worker.
"If you had previously enabled service workers in your production deployment and have decided that you would like to disable them for all your existing users, you can swap out the call to serviceWorkerRegistration. register() in src/index. js with a call to serviceWorkerRegistration. unregister().
Settings > Safari > Advanced > Experimental Features > Service Workers -- slide to OFF position.
You can use the chrome devtools, and under Application>Service Workers path select the Update on refresh checkbox
You can also use the Bypass for network checkbox to avoid Service worker's register event form firing.
Here is a brute-force approach:
const fn = () => {}; navigator.serviceWorker.register = () => new Promise(fn, fn);
(tested in Chrome Canary and Firefox Developer Edition)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With