동적 API URL 설정
This commit is contained in:
@@ -1,6 +1,29 @@
|
||||
import axios, { AxiosResponse, AxiosError } from "axios";
|
||||
|
||||
export const API_BASE_URL = "http://39.117.244.52:8080/api";
|
||||
// API 기본 URL 동적 설정 - 접속 도메인에 따라 최적 API URL 결정
|
||||
const getApiBaseUrl = (): string => {
|
||||
if (typeof window !== "undefined") {
|
||||
const currentHost = window.location.hostname;
|
||||
|
||||
// 로컬 개발환경
|
||||
if (currentHost === "localhost" || currentHost === "127.0.0.1") {
|
||||
return "http://localhost:8080/api";
|
||||
}
|
||||
// 내부 IP 접근 - 외부 IP로 통일
|
||||
else if (currentHost === "192.168.0.70") {
|
||||
return "http://39.117.244.52:8080/api";
|
||||
}
|
||||
// 외부 IP 접근
|
||||
else if (currentHost === "39.117.244.52") {
|
||||
return "http://39.117.244.52:8080/api";
|
||||
}
|
||||
}
|
||||
|
||||
// 서버 사이드 렌더링이나 기본값
|
||||
return process.env.NEXT_PUBLIC_API_URL || "http://39.117.244.52:8080/api";
|
||||
};
|
||||
|
||||
export const API_BASE_URL = getApiBaseUrl();
|
||||
|
||||
// JWT 토큰 관리 유틸리티
|
||||
const TokenManager = {
|
||||
|
||||
Reference in New Issue
Block a user