简体   繁体   English

如何在 heroku 上部署 react、trapi 应用程序

[英]How to deploy a react, strapi app on heroku

I'm creating a an app using react as the frontend and strapi as the backend with a mongobd database.我正在创建一个应用程序,使用 react 作为前端,trapi 作为后端,使用 mongobd 数据库。

So I have two folders at the root of the app client and server所以我在应用程序clientserver的根目录下有两个文件夹

Is it possible to deploy both folders like this on heroku.是否可以在heroku上部署这样的两个文件夹。

I have read in another tutorial that我在另一个教程中读到过

If deploying your backend to a provider that does not persist storage on the server like Heroku, the default Strapi local server upload will not work as your files on the server are automatically wiped periodically.如果将您的后端部署到像 Heroku 这样不在服务器上持久存储的提供程序,默认的 Strapi 本地服务器上传将不起作用,因为您在服务器上的文件会定期自动擦除。

Just trying to find the best way to deploy this app只是试图找到部署此应用程序的最佳方式

It just so happens that I just build a project like this.碰巧我只是建立了一个这样的项目。 For the frontend I used Gatsby and Strapi for the CMS.对于前端,我将 Gatsby 和 Strapi 用于 CMS。 I deployed the Strapi app on Heroku (and used a Postgresql database - you can add this as a plugin from the Heroku dashboard, or do the same with MongoDB) and the Gatsby app on Netlify (same thing you can do with a React app).我在 Heroku 上部署了 Strapi 应用程序(并使用了 Postgresql 数据库 - 您可以将其添加为 Heroku 仪表板中的插件,或使用 MongoDB 执行相同操作)和 Netlify 上的 Gatsby 应用程序(您可以使用 React 应用程序执行相同的操作) .

It's true that by default Heroku wipes your data once a day (I think), but since are connecting your app to Mongo that shouldn't be an issue.确实,默认情况下 Heroku 每天擦除一次您的数据(我认为),但是由于将您的应用程序连接到 Mongo,这应该不是问题。 Just add the DB variables to the respective fields in your Heroku app's dashboard.只需将 DB 变量添加到 Heroku 应用程序仪表板中的相应字段即可。

I like to keep the front and backend separate myself, so I would deploy them as separate repos, either on Heroku or anywhere else.我喜欢自己将前端和后端分开,因此我会将它们部署为单独的存储库,无论是在 Heroku 上还是在其他任何地方。

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

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