At Django website I have several applications. For each application I need separate ServiceWorker. Let's say, when user goes to
https://mysite/app/1 sw1.js is loaded, when to
https://mysite/app/2 sw2.js and so on.
All the service workers files are located at Amazon S3 bucket.
I can register service worker on the index page of each application in a normal way. However, the scope of the service worker is defined based on sw.js location which is S3 bucket path.
To change the scope I have to either place the sw.js to the root of each application what is impossible or to return extended http header 'Service-Worker-Allowed' what is restricted by S3
One of the solution is probably to use CloudFront/S3 with Lambda@Edge to return correct header but it looks too complex.
Is there any simpler solutions to define the correct scope of sw?