How to deploy React and Node.js on cPanel

Viewed 894

I am asking here because I have no idea what to do anymore. I want to deploy my React app that uses Nodejs as a server and I cannot find a proper article or forum to help me. They all only talk about how to setup Nodejs or how to setup React. Nothing on how to setup both at the same time. This is my first React project with Nodejs.

I am trying to deploy my React app using a Node.js as a server onto cPanel on my domain. When adding my React build folder to public_html then the front end is good and obviously Node is not working when I try to use the backend functionalities. When I go and setup a Node.js App in my cPanel I cannot get the js script to point to server/index.js, it only selects index.js in the root. Check image below:

enter image description here

I point my index.js with my server config to server/index.js in my Application startup file but it keeps going to the index.js in the app, not server/index.js.

My directory is as follows:

-app
  -build
  -node_modules
  -public
  -server
     -index.js (must use this one)
  -src
  -.env
  -package.json
  -index.js (keeps using this one)

How can I deploy my React app with Node server using cPanel? Please help.

0 Answers
Related