console.log 삭제
This commit is contained in:
@@ -2,38 +2,28 @@ import axios, { AxiosResponse, AxiosError } from "axios";
|
||||
|
||||
// API URL 동적 설정 - 환경별 명확한 분리
|
||||
const getApiBaseUrl = (): string => {
|
||||
console.log("🔍 API URL 결정 시작!");
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const currentHost = window.location.hostname;
|
||||
const currentPort = window.location.port;
|
||||
const fullUrl = window.location.href;
|
||||
|
||||
console.log("🌐 현재 접속 정보:", {
|
||||
hostname: currentHost,
|
||||
fullUrl: fullUrl,
|
||||
port: currentPort,
|
||||
});
|
||||
|
||||
// 로컬 개발환경: localhost:9771 또는 localhost:3000 → localhost:8080
|
||||
if ((currentHost === "localhost" || currentHost === "127.0.0.1") && (currentPort === "9771" || currentPort === "3000")) {
|
||||
console.log("🏠 로컬 개발 환경 감지 → localhost:8080/api");
|
||||
if (
|
||||
(currentHost === "localhost" || currentHost === "127.0.0.1") &&
|
||||
(currentPort === "9771" || currentPort === "3000")
|
||||
) {
|
||||
return "http://localhost:8080/api";
|
||||
}
|
||||
|
||||
// 서버 환경에서 localhost:5555 → 39.117.244.52:8080
|
||||
if ((currentHost === "localhost" || currentHost === "127.0.0.1") && currentPort === "5555") {
|
||||
console.log("🌍 서버 환경 (localhost:5555) 감지 → 39.117.244.52:8080/api");
|
||||
return "http://39.117.244.52:8080/api";
|
||||
}
|
||||
|
||||
// 기타 서버 환경 (내부/외부 IP): → 39.117.244.52:8080
|
||||
console.log("🌍 서버 환경 감지 → 39.117.244.52:8080/api");
|
||||
return "http://39.117.244.52:8080/api";
|
||||
}
|
||||
|
||||
// 서버 사이드 렌더링 기본값
|
||||
console.log("🖥️ SSR 기본값 → 39.117.244.52:8080/api");
|
||||
return "http://39.117.244.52:8080/api";
|
||||
};
|
||||
|
||||
@@ -73,18 +63,9 @@ apiClient.interceptors.request.use(
|
||||
(config) => {
|
||||
// JWT 토큰 추가
|
||||
const token = TokenManager.getToken();
|
||||
console.log("🔍 API 요청 토큰 확인:", {
|
||||
hasToken: !!token,
|
||||
tokenLength: token ? token.length : 0,
|
||||
tokenStart: token ? token.substring(0, 30) + "..." : "없음",
|
||||
url: config.url,
|
||||
method: config.method,
|
||||
});
|
||||
|
||||
if (token && !TokenManager.isTokenExpired(token)) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
console.log("✅ JWT 토큰 추가됨:", token.substring(0, 50) + "...");
|
||||
console.log("🔑 Authorization 헤더:", `Bearer ${token.substring(0, 30)}...`);
|
||||
} else if (token && TokenManager.isTokenExpired(token)) {
|
||||
console.warn("❌ 토큰이 만료되었습니다.");
|
||||
// 토큰 제거
|
||||
@@ -97,7 +78,6 @@ apiClient.interceptors.request.use(
|
||||
|
||||
// FormData 요청 시 Content-Type 자동 처리
|
||||
if (config.data instanceof FormData) {
|
||||
console.log("📎 FormData 감지 - Content-Type 헤더 제거");
|
||||
delete config.headers["Content-Type"];
|
||||
}
|
||||
|
||||
@@ -120,13 +100,6 @@ apiClient.interceptors.request.use(
|
||||
}
|
||||
}
|
||||
|
||||
console.log("🌐 API 요청 시 언어 정보:", {
|
||||
currentLang,
|
||||
globalVar: (window as unknown as { __GLOBAL_USER_LANG?: string }).__GLOBAL_USER_LANG,
|
||||
localStorage: typeof window !== "undefined" ? localStorage.getItem("userLocale") : null,
|
||||
url: config.url,
|
||||
});
|
||||
|
||||
if (config.params) {
|
||||
config.params.userLang = currentLang;
|
||||
} else {
|
||||
@@ -134,8 +107,6 @@ apiClient.interceptors.request.use(
|
||||
}
|
||||
}
|
||||
|
||||
console.log("📡 API 요청:", config.method?.toUpperCase(), config.url, config.params, config.data);
|
||||
console.log("📋 요청 헤더:", config.headers);
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
@@ -147,7 +118,6 @@ apiClient.interceptors.request.use(
|
||||
// 응답 인터셉터
|
||||
apiClient.interceptors.response.use(
|
||||
(response: AxiosResponse) => {
|
||||
console.log("✅ API 응답:", response.status, response.config.url, response.data);
|
||||
return response;
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
@@ -194,7 +164,6 @@ apiClient.interceptors.response.use(
|
||||
|
||||
// 401 에러 시 토큰 제거 및 로그인 페이지로 리다이렉트
|
||||
if (status === 401 && typeof window !== "undefined") {
|
||||
console.log("🔄 401 에러 감지 - 토큰 제거 및 로그인 페이지로 리다이렉트");
|
||||
localStorage.removeItem("authToken");
|
||||
|
||||
// 로그인 페이지가 아닌 경우에만 리다이렉트
|
||||
|
||||
@@ -79,12 +79,7 @@ export const menuApi = {
|
||||
// 관리자 메뉴 목록 조회
|
||||
getAdminMenus: async (): Promise<ApiResponse<MenuItem[]>> => {
|
||||
const response = await apiClient.get("/admin/menus");
|
||||
console.log("=== API 응답 데이터 ===");
|
||||
console.log("전체 응답:", response);
|
||||
console.log("응답 데이터:", response.data);
|
||||
if (response.data.success && response.data.data && response.data.data.length > 0) {
|
||||
console.log("첫 번째 메뉴 원본 데이터:", response.data.data[0]);
|
||||
console.log("첫 번째 메뉴 키들:", Object.keys(response.data.data[0]));
|
||||
}
|
||||
return response.data;
|
||||
},
|
||||
@@ -145,12 +140,9 @@ export const menuApi = {
|
||||
menuCode?: string;
|
||||
keyType?: string;
|
||||
}): Promise<ApiResponse<LangKey[]>> => {
|
||||
console.log("🔍 다국어 키 목록 조회 API 호출:", "/multilang/keys", params);
|
||||
|
||||
try {
|
||||
// Node.js 백엔드의 실제 라우팅과 일치하도록 수정
|
||||
const response = await apiClient.get("/multilang/keys", { params });
|
||||
console.log("✅ 다국어 키 목록 조회 성공:", response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("❌ 다국어 키 목록 조회 실패:", error);
|
||||
|
||||
Reference in New Issue
Block a user