0

I have two apps build in react using vite and I want to combine those two apps in one on the same port:

For example in nginx I want something like this:

http://localhost -> redirect to http://localhost:3000;

http://localhost/path-to-app2 -> redirect to http://localhost:4000;

What I tried with the apps in development mode:

server {
 listen 80;
 location / {
  proxy_pass http://localhost:3000;
 }
 location /path-to-app2 {
  proxy_pass http://localhost:4000;
 }
}

also I tried with builded apps:

server {
 listen 80;

 location / {
  root /usr/share/nginx/html/app1;
  index index.html index.htm;
  try_files $uri $uri/ /index.html =404;

 }
 location /path-to-app2 {
  root /usr/share/nginx/html/app2;
  index index.html index.htm;
  try_files $uri $uri/ /index.html =404;
 }
}

The problem is that all routes are redirected to location /. I also tried to change location / to location = / but also didn't work...

I also tried to app2 who has the path /path-to-app2 to add in package.json: "homepage": "/path-to-app2" but also didn't work. I don't succed to make the path / exact

I someone here who faced the same issue like me?

Florin D
  • 51
  • 4

0 Answers0