build(deploy): relative API base and a same-origin /api proxy

This commit is contained in:
LincPay
2026-08-15 15:33:21 +05:30
parent 627e11e9a9
commit 318b83625a
2 changed files with 32 additions and 2 deletions
+8 -2
View File
@@ -4,8 +4,14 @@ WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# VITE_UDYAM_API_BASE_URL is unset here, so the compiled-in default
# (http://udyamlinc-backend.lincpay/api/v1/udyam) is baked into the bundle.
# Vite inlines this at build time, so it is a build arg and not a runtime env
# var — changing it later means rebuilding the bundle, not restarting nginx.
#
# Relative on purpose. A bundle carrying no hostname serves from any domain and
# is same-origin with the API that nginx proxies at /api/, so the deployment
# never has a CORS origin to keep in sync.
ARG VITE_UDYAM_API_BASE_URL=/api/v1/udyam
ENV VITE_UDYAM_API_BASE_URL=$VITE_UDYAM_API_BASE_URL
RUN npm run build
# ── serve stage: nginx serving the static SPA on 5173 ──