How to deploy React App on AWS EC2 with nginx

2019-07-28 18:07发布

问题:

I have simple create-react-app on AWS EC2, I want to deploy my React app to AWS EC2 instance which I have already created and one of my Django application is running on it using gunicorn and nginx.

Now I want to deploy a react application to that ec2 instance and host the react app with another subdomain here. This react app requires to call APIs hosted to a different EC2 instance. When I do npm run build, it creates a build folder there and when i run serve -s build my webpage opens but API is not called.

So, what I want to achieve is:

  1. Make API run to the react application in production with axios.
  2. Correctly deploy React app to EC2 instance.

Kindly suggest how to achieve this?