Search code examples
reactjsgithubdeployment

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.


Solution

  • 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.