7

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?

DevB2F
  • 4,674
  • 4
  • 36
  • 60

3 Answers3

7

run serve -s from inside of the /build folder. exemple

C:\Users\zafriha\Desktop\myProject>build>cd..

C:\Users\zafriha\Desktop\myProject>npm install -g serve

C:\Users\zafriha\Desktop\myProject>serve -s build

Ait Friha Zaid
  • 1,222
  • 1
  • 13
  • 20
0

Had the same issue. Executing nx reset in the terminal solved it.

nx reset
Ruby
  • 1
  • 1
-1

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

DevB2F
  • 4,674
  • 4
  • 36
  • 60