Register Service Worker from a nested path #1756
Replies: 1 comment 2 replies
-
Hi, @prathamnemade. That's a great question. By design, a Service Worker treats its location as the root directory it controls. It will then control that root directory and any child directories, which means intercepting requests and being able to affect the outgoing traffic. You can, however, circumvent that design in a few ways. Listing them below. Option 1: Proxy the worker requestIf you can, create a proxy route on your server at
Option 2: User the
|
Beta Was this translation helpful? Give feedback.
-
I need help regarding the implementation/integration, when we have the service worker present in a different dir.
Currently, my service worker is in directory -
path1/path2/static/mockServiceWorker.js
But, my apis are on path -
path1/path2/api/someapi
As we can see the
mockServiceWorker.js
is present in thestatic
directory whereas the apis are on a different dir, how do i setupmsw
?The only possibility i can see now is to move the service worker to dir-
path1/path2/mockServiceWorker.js
; this is how i can make it work but i am forced to stick tostatic
path. Is there an easy way i can configure themockServiceWorker.js
?Beta Was this translation helpful? Give feedback.
All reactions