From 1a3f76031b3ea4f3b4f24abec6d4dd7bd6b61c19 Mon Sep 17 00:00:00 2001 From: merrycoral Date: Thu, 30 Oct 2025 02:09:39 +0900 Subject: [PATCH] =?UTF-8?q?Event=20API=20baseURL=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - shared/api/eventApi.ts: 개발 환경에서 상대 경로 사용 - 개발: /api/v1 (프록시 또는 Mock API 사용) - 프로덕션: {EVENT_HOST}/api/v1 - CORS 에러 및 네트워크 에러 해결 --- src/shared/api/eventApi.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shared/api/eventApi.ts b/src/shared/api/eventApi.ts index 4e9465f..d7aa1bb 100644 --- a/src/shared/api/eventApi.ts +++ b/src/shared/api/eventApi.ts @@ -2,10 +2,15 @@ import axios, { AxiosInstance } from 'axios'; // Event Service API 클라이언트 const EVENT_API_BASE_URL = process.env.NEXT_PUBLIC_EVENT_HOST || 'http://localhost:8080'; -const API_VERSION = process.env.NEXT_PUBLIC_API_VERSION || 'api'; +const API_VERSION = process.env.NEXT_PUBLIC_API_VERSION || 'v1'; + +// 개발 환경에서는 상대 경로 사용 (Next.js rewrites 프록시 또는 Mock API 사용) +// 프로덕션 환경에서는 환경 변수의 호스트 사용 +const isProduction = process.env.NODE_ENV === 'production'; +const BASE_URL = isProduction ? `${EVENT_API_BASE_URL}/api/${API_VERSION}` : `/api/${API_VERSION}`; export const eventApiClient: AxiosInstance = axios.create({ - baseURL: `${EVENT_API_BASE_URL}/${API_VERSION}`, + baseURL: BASE_URL, timeout: 30000, // Job 폴링 고려 headers: { 'Content-Type': 'application/json',