shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.75k stars 311 forks source link

Load service worker from CDN #426

Open Rishab1207 opened 1 year ago

Rishab1207 commented 1 year ago

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

shadowwalker commented 1 year ago

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.

Rishab1207 commented 1 year ago

Alright, thanks @shadowwalker.