I'm using msw to mock API request, and almost API develop is done, so I want to turn off serviceworker and I turn on / turn off bypass for network in developer mode's application tab
but still msw is running and intercepting requests...
I tried unregistering service worker but when I refresh, it is registered again...
I'm using mac.
MSW is running and intercepting requests after a page reload because your client-side JavaScript has a
worker.start()call. If you remove it, or call it conditionally, MSW will not register its Service Worker.In fact, MSW detects when you close your application's tab in the browser, and when the last one closes, it unregisters the worker automatically so it doesn't leave across different projects served on the same host. The only reason it registers back is when your code has
worker.start().This is a very long explanation of:
worker.start()call if you don't want the worker to register;worker.stop()at any point on runtime until the page refreshes.