Intercept HTTP requests in standalone browser script #2192
-
Hello, I have browsed through various repositories and discussions but couldn't find an answer to my question. <script src="https://mydomain/script.js" defer=""></script> and make it so that whenever a request is intercepted, a console log is displayed with the URL to which the request was made. I'm not sure if this is entirely off-topic or not. Thank you for your time and assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, @sorasful. Should the |
Beta Was this translation helpful? Give feedback.
Got it!
That's not going to work. MSW uses the Service Worker API in the browser. Since it allows you to intercept the traffic on a page, it has to be secure. One of its security measures is that the consumer has to serve the worker script. Just including a <script> tag will not do anything.
I generally advise against this pattern. Cross-domain network control is dangerous for both parties. If you can, avoid this and implement your API differently.