diff --git a/frontend/lib/api/dashboard.ts b/frontend/lib/api/dashboard.ts index 88306356..6cd98427 100644 --- a/frontend/lib/api/dashboard.ts +++ b/frontend/lib/api/dashboard.ts @@ -3,7 +3,27 @@ */ import { DashboardElement } from "@/components/admin/dashboard/types"; -import { API_BASE_URL } from "./client"; + +// API URL 동적 설정 +function getApiBaseUrl(): string { + // 클라이언트 사이드에서만 실행 + if (typeof window !== "undefined") { + const hostname = window.location.hostname; + + // 프로덕션: v1.vexplor.com → https://api.vexplor.com/api + if (hostname === "v1.vexplor.com") { + return "https://api.vexplor.com/api"; + } + + // 로컬 개발: localhost → http://localhost:8080/api + if (hostname === "localhost" || hostname === "127.0.0.1") { + return "http://localhost:8080/api"; + } + } + + // 서버 사이드 렌더링 시 기본값 + return "/api"; +} // 토큰 가져오기 (실제 인증 시스템에 맞게 수정) function getAuthToken(): string | null { @@ -17,6 +37,7 @@ async function apiRequest( options: RequestInit = {}, ): Promise<{ success: boolean; data?: T; message?: string; pagination?: any }> { const token = getAuthToken(); + const API_BASE_URL = getApiBaseUrl(); const config: RequestInit = { headers: {