next-pwa icon indicating copy to clipboard operation
next-pwa copied to clipboard

Load service worker from CDN

Open Rishab1207 opened this issue 3 years ago • 2 comments

Summary

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.

  1. So, Is there any way possible where we can change the request URL of service-worker?
  2. 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).

Versions

  • next-pwa: ^5.6.0
  • next: ^12.1.6

Rishab1207 avatar Nov 03 '22 17:11 Rishab1207

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.

shadowwalker avatar Dec 09 '22 06:12 shadowwalker

Alright, thanks @shadowwalker.

Rishab1207 avatar Dec 09 '22 07:12 Rishab1207