From be81aa1c8bb61d288c94b7000635c8d38d7c572e Mon Sep 17 00:00:00 2001 From: Fusion Date: Mon, 18 May 2026 11:09:37 +0200 Subject: [PATCH] fix: pass Vite env vars as Docker build args Vite reads env vars at build time, not runtime. The previous setup only set them in docker-compose 'environment' which is only available at container runtime. Now they are passed as build args so Vite can embed the correct API URL during the build process. - Add build args to web service in both compose files - Update Dockerfile to accept ARGs and set ENV for Vite - Fixes login redirect always going to localhost:8000 --- apps/web/Dockerfile | 6 ++++++ docker-compose.traefik.yml | 3 +++ docker-compose.yml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 3a406b2..ef50b17 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -12,6 +12,12 @@ RUN npm install # Copy source code COPY . . +# Accept build arguments for API and app URLs +ARG VITE_API_BASE_URL +ARG VITE_APP_URL +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} +ENV VITE_APP_URL=${VITE_APP_URL} + # Build production bundle RUN npm run build diff --git a/docker-compose.traefik.yml b/docker-compose.traefik.yml index 618afc5..ccddc4d 100644 --- a/docker-compose.traefik.yml +++ b/docker-compose.traefik.yml @@ -89,6 +89,9 @@ services: build: context: ./apps/web dockerfile: Dockerfile + args: + VITE_API_BASE_URL: ${API_PUBLIC_URL:-https://${API_DOMAIN}} + VITE_APP_URL: ${WEB_PUBLIC_URL:-https://${WEB_DOMAIN}} container_name: hq-web environment: VITE_API_BASE_URL: ${API_PUBLIC_URL:-https://${API_DOMAIN}} diff --git a/docker-compose.yml b/docker-compose.yml index e1be84c..bbcafb0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,6 +71,8 @@ services: build: context: ./apps/web dockerfile: Dockerfile + args: + VITE_API_BASE_URL: http://localhost:8000 container_name: hq-web environment: VITE_API_BASE_URL: http://localhost:8000