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

View File

@@ -4,16 +4,12 @@ WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
COPY . .
ARG VITE_API_BASE=/api
ARG VITE_WIZARD_PORT=18080
ENV VITE_API_BASE=$VITE_API_BASE
ENV VITE_WIZARD_PORT=$VITE_WIZARD_PORT
# API and wizard are proxied via nginx — no VITE_ env vars needed
RUN npm run build
# Production stage — lightweight static server, no nginx
FROM node:20-alpine
RUN npm install -g serve@14
WORKDIR /app
COPY --from=build /app/dist ./dist
# Production stage — nginx with reverse proxy
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["serve", "-s", "dist", "-l", "3000"]
CMD ["nginx", "-g", "daemon off;"]