How to deploy create-react-app in AWS EC2

前端 未结 4 456
梦如初夏
梦如初夏 2021-01-18 06:22

I am using react-router so I want to host in AWS Ec2. How to deploy the app and run permanently in the background or let me know if any other way

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-18 07:10

    I'm a little bit new to React, but I wanna add my experience here. I deployed my CRA app on AWS EC2 using Apache.

    • You follow this link to install Apache after launching the EC2 instance.
    • Build your react app and upload 'build' folder.

    Now done. Finally, make sure to use HashRouter rather than BrowserRouter. Because EC2 didn't allow the .htaccess file to redirect all requests to index.html, but replacing BrowserRouter with HashRouter helped me solve that issue. Hope this helps others save the time. Thanks.

提交回复
热议问题