From c076cd0b147105c0b3c9abdd2620d7faaa84099f Mon Sep 17 00:00:00 2001 From: dohyeons Date: Thu, 2 Oct 2025 17:28:52 +0900 Subject: [PATCH] =?UTF-8?q?=EB=98=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/deploy/docker-compose.yml | 4 ++-- docker/deploy/frontend.Dockerfile | 2 +- frontend/lib/api/externalCall.ts | 18 ++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docker/deploy/docker-compose.yml b/docker/deploy/docker-compose.yml index 63f4d0a8..9388b57e 100644 --- a/docker/deploy/docker-compose.yml +++ b/docker/deploy/docker-compose.yml @@ -35,12 +35,12 @@ services: context: ../../frontend dockerfile: ../docker/deploy/frontend.Dockerfile args: - - NEXT_PUBLIC_API_URL=https://api.vexplor.com + - NEXT_PUBLIC_API_URL=https://api.vexplor.com/api container_name: pms-frontend-prod restart: always environment: NODE_ENV: production - NEXT_PUBLIC_API_URL: https://api.vexplor.com + NEXT_PUBLIC_API_URL: https://api.vexplor.com/api NEXT_TELEMETRY_DISABLED: "1" PORT: "3000" HOSTNAME: 0.0.0.0 diff --git a/docker/deploy/frontend.Dockerfile b/docker/deploy/frontend.Dockerfile index 2730c925..01315ce1 100644 --- a/docker/deploy/frontend.Dockerfile +++ b/docker/deploy/frontend.Dockerfile @@ -20,7 +20,7 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED 1 # 빌드 시 환경변수 설정 (ARG로 받아서 ENV로 설정) -ARG NEXT_PUBLIC_API_URL=https://api.vexplor.com +ARG NEXT_PUBLIC_API_URL=https://api.vexplor.com/api ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL # Build the application diff --git a/frontend/lib/api/externalCall.ts b/frontend/lib/api/externalCall.ts index c500fe35..a8dd2ea9 100644 --- a/frontend/lib/api/externalCall.ts +++ b/frontend/lib/api/externalCall.ts @@ -34,6 +34,12 @@ export interface ValidationResult { */ // API URL 동적 설정 - 기존 client.ts와 동일한 로직 const getApiBaseUrl = (): string => { + // 1. 환경변수가 있으면 우선 사용 + if (process.env.NEXT_PUBLIC_API_URL) { + return process.env.NEXT_PUBLIC_API_URL; + } + + // 2. 클라이언트 사이드에서 동적 설정 if (typeof window !== "undefined") { const currentHost = window.location.hostname; const currentPort = window.location.port; @@ -45,18 +51,10 @@ const getApiBaseUrl = (): string => { ) { return "http://localhost:8080/api"; } - - // 서버 환경에서 localhost:5555 → 39.117.244.52:8080 - if ((currentHost === "localhost" || currentHost === "127.0.0.1") && currentPort === "5555") { - return "http://39.117.244.52:8080/api"; - } - - // 기타 서버 환경 (내부/외부 IP): → 39.117.244.52:8080 - return "http://39.117.244.52:8080/api"; } - // 서버 사이드 렌더링 기본값 - return "http://39.117.244.52:8080/api"; + // 3. 기본값 + return "http://localhost:8080/api"; }; export class ExternalCallAPI {