Score:0

How I combine multiple react apps in one app

bn flag

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?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.