1
0
forked from baron/baron-sso

API 클라이언트 및 개발 서버 설정 변경

This commit is contained in:
2026-02-11 17:33:54 +09:00
parent 66c9b859dc
commit 7a25cf40aa
2 changed files with 15 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
import axios from "axios"; import axios from "axios";
import { userManager } from "./auth";
const apiClient = axios.create({ const apiClient = axios.create({
baseURL: baseURL:
@@ -7,15 +8,15 @@ const apiClient = axios.create({
"/api/v1", "/api/v1",
}); });
apiClient.interceptors.request.use((config) => { apiClient.interceptors.request.use(async (config) => {
// TODO: IdP 중립 Auth 레이어 연동 시 세션 토큰을 주입한다. // OIDC Access Token 주입
const sessionToken = window.localStorage.getItem("admin_session"); const user = await userManager.getUser();
if (sessionToken) { if (user?.access_token) {
config.headers.Authorization = `Bearer ${sessionToken}`; config.headers.Authorization = `Bearer ${user.access_token}`;
} }
// TODO: 테넌트 선택 값을 보관하고 헤더로 전달한다. // TODO: 테넌트 선택 값을 보관하고 헤더로 전달한다.
const tenantId = window.localStorage.getItem("admin_tenant"); const tenantId = window.localStorage.getItem("dev_tenant_id"); // 키 이름을 좀 더 명확하게 변경 고려
if (tenantId) { if (tenantId) {
config.headers["X-Tenant-ID"] = tenantId; config.headers["X-Tenant-ID"] = tenantId;
} }
@@ -26,7 +27,11 @@ apiClient.interceptors.request.use((config) => {
apiClient.interceptors.response.use( apiClient.interceptors.response.use(
(response) => response, (response) => response,
(error) => { (error) => {
// TODO: 401/403 응답 시 로그인/재인증 플로우로 리다이렉션한다. if (error.response?.status === 401) {
// 401 발생 시 로그인 페이지로 리다이렉트하거나 토큰 갱신 로직 필요
// 여기서는 간단히 리다이렉트 처리 (userManager 사용)
userManager.signinRedirect();
}
return Promise.reject(error); return Promise.reject(error);
}, },
); );

View File

@@ -13,4 +13,7 @@ export default defineConfig({
}, },
}, },
}, },
esbuild: {
// drop: process.env.APP_ENV === "production" ? ["console", "debugger"] : [],
},
}); });