There’s a great overview of how to use Service Workers to make local development much easier (especially if you’re trying to hit an API that you want to run locally). This is a medium link, so if you’ve run out of free articles you can use this tweet to see it https://twitter.com/justinavery/status/1200025733361479682), or if you want to go straight to the repository it’s here (https://github.com/DannyMoerkerke/sw-proxy)
Service workers are usually used in conjunction with progressive web apps and allow the interception of all network traffic to and from a website.
That means you can intercept any request your app makes and respond to it in virtually any way you want.
The main use case for a service worker is to make a website work offline, but since you can intercept network traffic, you can also use it to run a proxy server or to serve mock responses, right in your browser.An excerpt from How To Run a Proxy Server Inside Your Browser