fix: proxy web /api routes to api container
This commit is contained in:
@@ -15,6 +15,7 @@ RUN npm run build && npm run build:api
|
||||
|
||||
FROM nginx:alpine AS web
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx.default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
FROM node:22-alpine AS runtime-base
|
||||
WORKDIR /app
|
||||
|
||||
@@ -100,7 +100,7 @@ Notes:
|
||||
- `APP_PORT`
|
||||
- `COOKIE_SECRET`
|
||||
- `GOOGLE_MAPS_SERVER_KEY`
|
||||
- `VITE_API_BASE_URL`
|
||||
- `VITE_API_BASE_URL` (use `/api` when web and API share a domain via the nginx proxy)
|
||||
- `VITE_GOOGLE_MAPS_PLATFORM_KEY`
|
||||
2. Create the shared Docker network if it does not exist:
|
||||
`docker network create locale-all || true`
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:4000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user