I get this error when trying to register a service worker:
Failed to register ServiceWorker: Bad HTTP response code (404) was received while fetching the script.
I work with ionic, and this is what I have in app.js:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function(err) {
console.log('ServiceWorker registration failed: ', err);
});
}else {
console.log('No service-worker on this browser');
}
In the directory, I have a service-worker.js file next to app.js in the same folder.
Using the latest version of chrome on the ubuntu desktop.
source
share