I'm trying to deploy multiple projects on same path.
I'm working with a virtualbox using ubuntu. I've created a folder called multiprojects and inside there are 3 folders with one project inside eachone: demo, project1 and project2.
demo folder contains all files builded after call npm run build on demo project.
project1 folder contains a folder, with name build, that contains all files buided after call npm run build on project1.
project2 folder contains a folder, with name build, that contains all files buided after call npm run build on project2.
Also, project1 contains "homepage" in package.json that redirect to project1. "homepage": "/project1". project2 contains "homepage" in package.json that redirect to project2. "homepage": "/project2" and demo project doesnt contains homepage in pacakage.json
Each projeact has in App.js is own public path:
For example, in demo project has as a publicPath /demo, in project1 /project1 and finally in project2 /project2
const publicPath = "/demo";
return (
translations &&
styles && (
<BrowserRouter basename={publicPath}>
<ToastProvider>
<IntlProvider
key={settings.locale}
locale={settings.locale}
defaultLocale="en"
messages={translations[settings.locale]}
>
<Routes />
</IntlProvider>
</ToastProvider>
</BrowserRouter>
)
And this is my nginx config:
server {
listen 8090;
server_name localhost;
index index.html index.htm;
location /project1 {
root /home/osboxes/Documents/multiproject/project1/build;
try_files $uri $uri/ /index.html;
}
location /project2 {
root /home/osboxes/Documents/multiproject/project2/build;
try_files $uri $uri/ /index.html;
}
location / {
root /home/osboxes/Documents/multiproject/demo;
try_files $uri $uri/ /index.html;
}
}
I have two questions: