skip to Main Content

I would like to deploy my react app onto my personal website. I currently have it deployed onto to heroku and have that linked on my personal site. But I would like to eliminate heroku from the equation and have everything on my own site. Whenever I try to deploy it, I upload the build files into my file manager public_html. But when I try to open it, all I get is a blank page.
I have my vanilla JS projects up just fine.

My question is how do I deploy my react app, through cpanel, onto my existing site.

I’ve read through some stack pages already and tried npm run build and posting the zip files as well as the normal files to my cpanel file manager. But it only gives me a blank page.
When I open up dev tools for the blank page I can see that it is the html file I want but and it has the links to my build files but it’s just not running them for some reason. The console is giving me an error “Failed to load resource: the server responded with a status of 404 ()”
I’ve tried changing the homepage destination as well.

I believe I’m just missing something really simple because I’m having a hard time finding any help on this one. I’m relatively new to react and deploying react apps so if someone could help me I would be very grateful.

I don’t know if I am uploading the files to my file manager in cpanel wrong or if I’m doing something wrong with npm run build.

My git repo is here
https://github.com/brandondorner/4-Day-Forecast-Weather-App

Thank you.

2

Answers


  1. To deploy your react app into your web site just follow these steps :

    1. Build your react app using : npm run build
    2. Go to the app folder then to the build subfolder and you need to upload all contents to your server into the public_html folder

    I have tested these steps using create-react-app this is the ordinary way to do it, if it doesn’t work then try to check the error from the browser console

    Login or Signup to reply.
  2. It appears you need to change the homepage parameter in your configuration file and change few settings with your router

    See this as I think it can help https://scottvinkle.me/blogs/work/how-to-deploy-a-react-app-to-a-subdirectory

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search