I've a project, where we have all the static resources stored inside an AWS s3 bucket. So, while fetching sw.js (service worker), next-pwa is trying to locate the service-worker at <OUR_DOMAIN>/sw.js but in our case the service-worker is available at CDN (<SOME_AWS_STRING>/sw.js), so we are getting 404 while fetching service-worker.
So, Is there any way possible where we can change the request URL of service-worker?
If not, is there any other easy way to go about this situation? (We would've to make changes in our AWS architecture, if we want to serve the service-worker from our domain, so for now I'm avoiding that solution).
You cannot serve service work js from a different domain, it’s strictly not allowed by browser for security reason. You will have to find a way to serve from your domain.
Summary
I've a project, where we have all the static resources stored inside an AWS
s3
bucket. So, while fetchingsw.js
(service worker), next-pwa is trying to locate the service-worker at<OUR_DOMAIN>/sw.js
but in our case the service-worker is available at CDN (<SOME_AWS_STRING>/sw.js
), so we are getting404
while fetching service-worker.Versions
next-pwa
:^5.6.0
next
:^12.1.6