简体   繁体   English

如何在服务器上托管React App和Node API

[英]How to host react app and node api on server

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. 我有一个Web应用程序,其中前端是在reactJs上构建的,后端是在nodejs上构建的。现在我想托管这个应用程序,因为我以前从未托管过任何react应用程序。 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. 所以我打算将我的react部分托管在heroku上的Amazon S3和nodejs api上。我想知道这种组合是否可以完美地工作,或者我需要尝试一些不同的东西。

Please let me know how can I host this full stack app any idea will be appreciated. 请让我知道如何托管这个全栈应用程序,任何想法将不胜感激。

THANKS 谢谢

There are two ways: 有两种方法:

  1. You can host your front-end on heroku itself. 您可以将前端托管在heroku本身上。 Build your react project and place your output folder in the node static files folder. 构建您的react项目并将输出文件夹放置在节点静态文件文件夹中。
  2. If you want to use separate hosting, I would suggest you to use Netlify for front-end side. 如果要使用单独的托管,建议您将Netlify用于前端。

Let me know if it helps. 让我知道是否有帮助。

S3 is storage service, so I don't think it's a good way to deploy your React app. S3是存储服务,因此我认为这不是部署React应用程序的好方法。 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. 您需要一台能够运行React应用程序Web服务器的服务器,例如serve ,您的选择可能是AWS的EC2。

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). 您可以将Nodejs API和React部件部署在任何地方(服务器),并确保它们可以完美地连接在一起(成功地从后端调用API)。 Additionally, you can also try to use NGINX as reverse-proxy to your React app. 此外,您还可以尝试将NGINX用作React应用程序的反向代理。

Reference: CreateReactApp Deployment 参考: CreateReactApp部署

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM