Search code examples
reactjslinuxapachereverse-proxyserve

React app fails to run with Apache reverse proxy


I'm using the reverse-proxy apache2 module to forward any request from https://my_server.com/test_app/ to the react production app, which is running on :3000.

If i'm using https://my_server.com:3000, everything works fine. But https://my_server.com/test_app/ fails then to get the static files and react fails to load. It seems to request the static files on the port 80, but my react app is running on 3000.

How can i fix this?

package.json

{
  "private": true,
  "homepage": "/",
  ...
}

httpd.conf

ProxyPass /test_app http://localhost:3000

Console output


Solution

  • Instead of using serve, i just placed the contents of the build into a directory in /var/www/html/<Some-Directory> (So i'm using Apache only). I had to define basename for the <Router /> and update my links, but seems to work fine for now.