I have a production-ready site which uses Next and want to implement the service worker to cache the images that we get. Below are the configuration that I use:
So, the manifest.json can be seen on the application tab on developer tools but it shows me No matching service worker detected. On the console, I see this error:
SW registration failed: TypeError: Failed to register a ServiceWorker for scope ('https://placeholder-domain.com/') with script ('https://placeholder-domain.com/service-worker.js'): A bad HTTP response code (404) was received when fetching the script.
When I try to access the above URL (https://placeholder-domain.com/service-worker.js), it actually shows me the service worker source code, so I guess it actually exists but something (I don't know what it is) failed to fetch it.
Versions
next: ^7.0.2
next-offline: ^5.0.0
koa: ^2.6.2
Browser
Brave 1.4.95
Google Chrome 80.0.3987.122
Can anyone guide me to fix it? I've been trying to register the service worker manually but it still shows me the same error.
Issue and steps to reproduce
I have a production-ready site which uses Next and want to implement the service worker to cache the images that we get. Below are the configuration that I use:
next.config.js
_document.js
Koa routes
So, the manifest.json can be seen on the
application
tab on developer tools but it shows meNo matching service worker detected
. On the console, I see this error:When I try to access the above URL (
https://placeholder-domain.com/service-worker.js
), it actually shows me the service worker source code, so I guess it actually exists butsomething
(I don't know what it is) failed to fetch it.Versions
Browser
Can anyone guide me to fix it? I've been trying to register the service worker manually but it still shows me the same error.