skip to Main Content

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.

enter image description here

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


  1. Chosen as BEST ANSWER

    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:

    ProxyPass / http://localhost:5001/
    ProxyPassReverse / http://localhost:5001/
    

    to:

    ProxyPass / http://my-server-ip:5001/
    ProxyPassReverse / http://my-server-ip:5001/
    

    solved the problem


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

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