[verified] route app-dev API through same-origin proxy

This commit is contained in:
kcar 2026-06-07 20:43:20 +01:00
parent 7326b9f3be
commit 7db852aaff
2 changed files with 13 additions and 2 deletions

View File

@ -61,6 +61,12 @@ RUN echo 'server { \
proxy_set_header X-Real-IP $remote_addr; \
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
} \
location /__ccapi/ { \
proxy_pass http://192.168.0.64:18000/; \
proxy_set_header Host $host; \
proxy_set_header X-Real-IP $remote_addr; \
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
} \
location /api/ { \
proxy_pass http://192.168.0.64:18000/api/; \
proxy_set_header Host $host; \

View File

@ -16,8 +16,13 @@ services:
context: .
dockerfile: Dockerfile
args:
VITE_API_BASE: ${VITE_API_BASE:-}
VITE_API_URL: ${VITE_API_URL:-}
# app-dev is served by nginx on the app host; browser API calls must stay
# same-origin and pass through Dockerfile's /__ccapi proxy. The proxy
# strips that prefix before forwarding, preserving mixed backend routes
# such as /api/exam, /me/bootstrap, and /database/timetable.
# .env.dev still points at the LAN API for local Vite/dev tooling.
VITE_API_BASE: /__ccapi
VITE_API_URL: /__ccapi
VITE_APP_NAME: ${VITE_APP_NAME:-Classroom Copilot}
VITE_APP_HMR_URL: ${VITE_APP_HMR_URL:-}
VITE_DEV: ${VITE_DEV:-false}