How to host react app and node api on server

All we need is an easy explanation of the problem, so here it is.

I have a web app in which front-end is made on reactJs and backend is built on nodejs.Now I want to host this app as I have never host any react app before.
SO what I am planning is to host my react part on amazon S3 and nodejs api on heroku.I want to know will this combination work perfectly or I need to try something different.

Please let me know how can I host this full stack app any idea will be appreciated.

THANKS

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

There are two ways:

  1. You can host your front-end on heroku itself. Build your react project and place your output folder in the node static files folder.
  2. If you want to use separate hosting, I would suggest you to use Netlify for front-end side.

Let me know if it helps.

Method 2

S3 is storage service, so I don’t think it’s a good way to deploy your React app. You need a server that has ability to run web server for React application, for example serve, and your option may be EC2 of AWS.

You can deploy your Nodejs API and React part on anywhere (server) and just make sure they can connect together perfectly (call API from backend successfully). Additionally, you can also try to use NGINX as reverse-proxy to your React app.

Reference: CreateReactApp Deployment

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply