fix: nginx reverse proxy for API/wizard, fix Object.entries null crash

- Replace serve with nginx for proper reverse proxy
- /api/* proxied to backend:8000, /wizard/* proxied to wizard:8080
- Eliminates CORS issues (same-origin requests)
- Fixes SPA fallback returning 200 for API routes (was hiding backend-down state)
- Add null guards on Object.entries for dashboard stats
- Remove VITE_API_BASE/VITE_WIZARD_PORT build args (no longer needed)
This commit is contained in:
zhi
2026-03-11 09:43:06 +00:00
parent f8fac48fcc
commit a655e41822
6 changed files with 40 additions and 17 deletions

29
nginx.conf Normal file
View File

@@ -0,0 +1,29 @@
server {
listen 3000;
root /usr/share/nginx/html;
index index.html;
# Backend API proxy
location /api/ {
proxy_pass http://backend:8000/;
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_connect_timeout 5s;
proxy_read_timeout 30s;
}
# Wizard API proxy (setup phase only)
location /wizard/ {
proxy_pass http://wizard:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 5s;
proxy_read_timeout 10s;
}
# SPA fallback — only for non-API, non-asset routes
location / {
try_files $uri $uri/ /index.html;
}
}