简体   繁体   English

部署一个使用 JSON 服务器作为后端的 React 应用程序,

[英]Deploying a react app that uses a JSON-server as backend,

I recently started using Heroku for my deployments.我最近开始使用 Heroku 进行部署。 So far I only used it to deploy front-end react apps which were fairly straight forward.到目前为止,我只用它来部署相当简单的前端 React 应用程序。 But now I am trying to deploy a full-stack react app that uses a JSON-server as the backend.但现在我正在尝试部署一个使用 JSON 服务器作为后端的全栈反应应用程序。 During the development process, I used concurrently to run the JSON server and the react app at the same time.开发过程中,我使用concurrently同时运行JSON服务器和react app。 I am not really sure how to create a static build for it and deploy it on Heroku as a single instance since the JSON server and react-app are two separate processes.我不太确定如何为其创建 static 构建并将其作为单个实例部署在 Heroku 上,因为 JSON 服务器和 react-app 是两个独立的进程。 Any help here will be highly appreciated.这里的任何帮助将不胜感激。 Thank you.谢谢你。

Github link to the project - https://github.com/Syndicate555/IT-Logger Github 项目链接 - https://github.com/Syndicate555/IT-Logger

package.json file package.json 文件

file structure文件结构

I saw that you are using CRA in building your app, you have two options我看到您正在使用 CRA 构建您的应用程序,您有两种选择

  1. Create another heroku instance that acts as your JSON-Server and configure it there创建另一个 heroku 实例作为您的 JSON-Server 并在那里配置它
  2. (preferred) - Use CRA with a express backend and use express to serve your CRA Application - Steps are here => https://dev.to/loujaybee/using-create-react-app-with-express (首选)- 将 CRA 与 express 后端一起使用并使用 express 为您的 CRA 应用程序提供服务 - 步骤在这里 => https://dev.to/loujaybee/using-create-react-app-with-express

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

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