Description
This is my project location.
root
- service-worker.js
- themes
.
.
- mytheme
- assets
- javascript
- app.js
I want to implement october-cms with service-worker and I have to put my service-worker.js at root of my project, so how can i call service-worker.js from app.js?
here is my app.js
if ('serviceWorker' in navigator) {
window.addEventListener('load', () =>
navigator.serviceWorker.register('service-worker.js')
.then(registration => {
console.log('Service Worker registered');
})
.catch(err => console.log('SW registration failed')))
}
and here is error i got.
A bad HTTP response code (404) was received when fetching the script.
Failed to load resource: net::ERR_INVALID_RESPONSE
@ayumihamsaki you're a PRO when it comes to serviceWorker. Could you look at this issue when you have a minute?
I had fixed this issue by add the root path to .htaccess file.
##
## White listed folders
##
.
.
.
RewriteCond %{REQUEST_FILENAME} !service-worker.js <<<< added this line
.
.
.
I don't know another solution but this worked for me.
@w20k Thanks lol
@annop-kongdeedai Yah I have done what you are asking for,...
It should then work just fine :+1:
Think you can close this issue now.
Most helpful comment
@w20k Thanks lol
@annop-kongdeedai Yah I have done what you are asking for,...
It should then work just fine :+1: