should i use a proxy middleware on production?

2.6k views Asked by At

I separated my frontend from my backend and I am configuring my frontend part. I am doing API requests to the backend with a proxy middleware in production now and my question is, can it harm my frontend app in anyway? is there anything why I shouldn't use a middleware proxy for this?

for me, a middleware proxy is a smooth solution to communicate with the backend and everything works out of the box.

the other option would be to setup a bunch of CORS exceptions but I am not happy with that.

1

There are 1 answers

2
Guru Prasad On BEST ANSWER

Yes, but only if you're handling the scaling case.

Keep in mind that JavaScript is single-threaded. While NodeJS is quite efficient, at some point it is likely that user's requests will begin to timeout since the single thread isn't able to service all the requests. When that happens, you may end up needing to re-design your application.

Take a look at pm2 as well as cluster mode if you haven't already. As long as your proxy middleware is configured to work in tandem with this, you should be fine.