25 lines
685 B
TypeScript
25 lines
685 B
TypeScript
|
|
/**
|
||
|
|
* 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;
|
||
|
|
}
|