Skip to content

Setting serviceWorker url to another relative path does not work #745

Answered by kettanaito
samadadi asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @samadadi.

Note that moving the worker script changes the scope at which it can intercept requests. I highly recommend reading through this to understand this behavior better.

When you move mockServiceWorker.js to /mocks, the worker, and thus MSW, cannot intercept requests that originate from pages other than /mocks/* (i.e. from the homepage of your application). I can see the http://localhost:3000/mocks/mockServiceWorker.js script loaded successfully, as well as the MSW activation message printed. These two factors mean that MSW has been successfully enabled. The /api/graphql request is not intercepted because it's performed from the root / of your application, which is outside of t…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@samadadi
Comment options

Answer selected by kettanaito
Comment options

You must be logged in to vote
1 reply
@kettanaito
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants