From c2a2307b34bc6d14e13c77c6c9bd2622eb921eca Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Wed, 3 Dec 2025 00:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9E=84=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 +++- frontend/Dockerfile | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 89d7036..df516a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,7 +103,9 @@ services: context: ./frontend dockerfile: Dockerfile args: - VITE_API_BASE_URL: ${VITE_API_BASE_URL:-http://localhost/api} + # Don't set VITE_API_BASE_URL to use relative path /api (recommended) + # This allows the frontend to work with any domain/IP + VITE_API_BASE_URL: ${VITE_API_BASE_URL:-} container_name: cosmo_frontend restart: unless-stopped volumes: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index f9df441..c010e4d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -17,8 +17,9 @@ RUN npm install # Copy source code COPY . . -# Build argument for API URL -ARG VITE_API_BASE_URL=http://localhost/api +# Build argument for API URL (optional) +# If not set, frontend will use relative path /api (recommended for production) +ARG VITE_API_BASE_URL ENV VITE_API_BASE_URL=$VITE_API_BASE_URL # Build the application (skip TypeScript check for faster builds)