Friday 24 May 2019

HTTP requests Node and React JS

I have a node and react application in which the latter was created with CRA. During development, the react app is usually at port 3001 and the node app is at 3000. Everything works fine since they are running on different processes and on different ports. The problem arises when I deploy it on the cloud. For deployment, I build my react app and once this is done, I put it inside my node server. Since during development, they were on different ports, everything worked fine, but now, since they are both running on the same port, making calls to the backend do not work with the same URL as during development. One way around this, has been to change this URL on the react side with my main public domain, essentially making the calls appear as if they were coming from the outside world, but in reality, they come from within. Im sure there is a cleaner and more proffesional way to go around this no?Thanks!

Submitted May 24, 2019 at 11:19AM by sebasjuan94

No comments:

Post a Comment