Running MSW in production #1012
-
Hey, I'll be working on a POC page that needs data from endpoints that are being developed for the next weeks or so. My page will be served on a hidden url, and the endpoints will be brand new so there's not chance that I "override" an endpoint if I enable MSW in production (I believe) My question here is, would it be safe/ok to enable MSW in prod for this particular case? Possible downsides of this approach
Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, @alejandronanez. You can use MSW in production for your POC. Endpoints you mock don't have to exist at all, MSW will perform request path matching regardless if the endpoint exists (that's the entire point!). There are no downsides as to using the worker in production, except your users communicating with the mocked API. In the case of demos and POCs that's an affordable limitation, I think.
Once you enable the production endpoints, deploy the next version of your app where you don't call
|
Beta Was this translation helpful? Give feedback.
Hey, @alejandronanez.
You can use MSW in production for your POC. Endpoints you mock don't have to exist at all, MSW will perform request path matching regardless if the endpoint exists (that's the entire point!).
There are no downsides as to using the worker in production, except your users communicating with the mocked API. In the case of demos and POCs that's an affordable limitation, I think.
Once you enable the production endpoints, deploy the next version of your app where you don't call
worker.start()
. There's a self-destructive mechanism built-in i…