在同一存储库中的前端和后端的github页面上部署React应用 [英] Deploying react app on github pages front and backend in the same repository

查看:52
本文介绍了在同一存储库中的前端和后端的github页面上部署React应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将带有后端的React应用程序部署到github页面上的同一存储库中。一切正常,直到我添加了后端代码。我可以部署前端,但无法弄清楚如何将后端部署到github。
在我的package.json中,我有以下内容:

I am trying to deploy a react app with the backend into the same repository on github pages. It all works fine until I add the backend code to it. I can deploy the front-end, but I cannot figure out how to deploy the backend to github. In my package.json I have the followings:

....
    "scripts": {
    "start": "react-scripts start",
    "server": "nodemon server.js",
    "client": "npm run start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  }
...

我已将其推送到github。已安装gh-pages软件包。
我已添加

I have pushed it to github. Installed gh-pages package. I have added

"homepage" : "https://[your-user-name].github.io/[your-repo-name]/"
"predeploy":
"deploy":

我认为这是我要去的地方。我知道应该指定什么预部署和部署,但是我尝试输入一千个不同的版本,但出现错误。

I think this is where I am going wrong. I know what predeploy and deploy should specify, but I have tried to enter a thousand different versions and I am getting error.

推荐答案

Github页面将不执行任何服务器端代码。您只能上传静态文件(html,css,js,图像等)。

Github pages will not execute any serverside code. You may only upload static files (html,css,js, images, etc.).

为了拥有托管后端,您应该寻找其他服务,例如Google Cloud ,AWS Lambda,Heroku等。

In order to have a hosted backend you should look for another service like Google Cloud, AWS Lambda, Heroku, etc.

这篇关于在同一存储库中的前端和后端的github页面上部署React应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆