Merge branch 'main' into feature/screen-management

This commit is contained in:
kjs
2025-10-24 15:40:35 +09:00
9 changed files with 487 additions and 141 deletions

View File

@@ -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<T>(
options: RequestInit = {},
): Promise<{ success: boolean; data?: T; message?: string; pagination?: any }> {
const token = getAuthToken();
const API_BASE_URL = getApiBaseUrl();
const config: RequestInit = {
headers: {

View File

@@ -0,0 +1,24 @@
/**
* API URL 유틸리티
* 프로덕션/개발 환경에 따라 올바른 API URL을 반환
*/
export function getApiUrl(endpoint: string): string {
// 클라이언트 사이드에서만 실행
if (typeof window !== "undefined") {
const hostname = window.location.hostname;
// 프로덕션: v1.vexplor.com → https://api.vexplor.com
if (hostname === "v1.vexplor.com") {
return `https://api.vexplor.com${endpoint}`;
}
// 로컬 개발: localhost → http://localhost:8080
if (hostname === "localhost" || hostname === "127.0.0.1") {
return `http://localhost:8080${endpoint}`;
}
}
// 기본값: 상대 경로
return endpoint;
}