I am deploying a React app to my Apache server.
I can access the app on my-ip:5001, but when I go to my domain it gives me
“404 the requested path could not be found”. Btw. the domain has been set up and worked with an html file before working with react.
I did npm run build
and placed the build folder in the root of my server.
Made no changes to the package.json file.
I run the server using: serve -s -l 5001
Apache conf file:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName somedomain.com
ServerAlias www.somedomain.com
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:5001/
ProxyPassReverse / http://localhost:5001/
</VirtualHost>
</IfModule>
Any idea what might be going on here?
2
Answers
New answer: There is no need to run the serve command on the server. Just put the build folder on the server. Inside the .conf apache file make the DocumentRoot path point to the build folder.
Old answer: Changing these lines:
to:
solved the problem
run serve -s from inside of the /build folder. exemple
C:UserszafrihaDesktopmyProject>build>cd..
C:UserszafrihaDesktopmyProject>npm install -g serve
C:UserszafrihaDesktopmyProject>serve -s build