I need help to install my react project with Cpanel (O2switch host). See my project :
For my server I use Sequelize
to manage ma data base.
I followed steps provids on the web :
Step 0 : Create the database (if you need it).
Step 1 :
Add into package.json
, contains into my client
file, the following code : "homepage": ".",
Step 2 :
npm run build
into my client
file to create build
file (in red into the previous picture).
Step 3 :
Make a .htaccess
it will look like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Step 4 : Create my nodeJS server on Cpanel
Step 5 :
Go inside my Cpanel > file directory > monGouvernement
:
And add into public
all files from my build
file.
After, add all files from my server
file as below (without node_modules file) :
Step 6 :
Go back to my nodeJs_setup to click on "Run NPM install" to install dependencies and create node_modules
files.
At this step, my database is created. But my front-end doesn't work. See what my browser show me:
I don't understand the reason of it. Could help me to solve this issus please ?
Ok I solved my problem.
The answer is : I didn't add my build
file at the right place. On my O2Switch Cpanel I'm hosting my domaine name and my nodeJs server (that I created with the setup_NodeJs_app). So, I got two files in my file manager
:
The first one is for my domaine name. The second one is for my nodeJs server.
So I have to add my build
file into my domaine (mon-gouvernement.fr) name like this :
And my server files into the other one (monGouvernement) :
Like this, everything work perfectly.