Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying react app on github pages front and backend in the same repository

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\""
  }
...

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.

like image 506
Gabriella Csernus Avatar asked Oct 24 '18 13:10

Gabriella Csernus


People also ask

Can I deploy React app to GitHub Pages?

The simplicity of deploying a static website with GitHub Pages is a process that can be easily transferred to React applications. With just a few steps, it's easy to host a React app on GitHub Pages for free or build it to deploy on your own custom domain or subdomain.

Can I have a backend with GitHub Pages?

Github pages will not execute any serverside code. You may only upload static files (html,css,js, images, etc.). In order to have a hosted backend you should look for another service like Google Cloud, AWS Lambda, Heroku, etc.


1 Answers

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

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

like image 153
giraffesyo Avatar answered Sep 22 '22 19:09

giraffesyo