From 044db723f0843668d24c6ff8d8e4fd7250e075fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=88=98=ED=98=84?= Date: Mon, 25 May 2026 21:50:10 +0900 Subject: [PATCH] add: get cookie on social login --- src/api/auth.ts | 4 ++++ src/api/axios.ts | 11 ++++++----- src/contexts/AuthProvider.tsx | 8 ++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/api/auth.ts b/src/api/auth.ts index 3ad719e..ce017ee 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -68,6 +68,10 @@ export const refresh = async () => { return user; }; +export const establishSession = async () => { + await api.post("/auth/session"); +}; + // health check export const healthCheck = async () => { const res = await api.get("/health"); diff --git a/src/api/axios.ts b/src/api/axios.ts index 3bc772a..457f459 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -28,12 +28,12 @@ api.interceptors.request.use( (config) => { const url = config.url ?? ""; - const isAuthApi = + const skipsAuthorizationHeader = url.includes("/auth/login") || url.includes("/auth/register") || url.includes("/auth/refresh"); - if (isAuthApi) { + if (skipsAuthorizationHeader) { delete config.headers.Authorization; return config; } @@ -56,12 +56,13 @@ api.interceptors.response.use( const originalRequest = error.config; const url = originalRequest?.url ?? ""; - const isAuthApi = + const skipsRefreshRecovery = url.includes("/auth/login") || url.includes("/auth/register") || - url.includes("/auth/refresh"); + url.includes("/auth/refresh") || + url.includes("/auth/session"); - if (isAuthApi) { + if (skipsRefreshRecovery) { return Promise.reject(error); } diff --git a/src/contexts/AuthProvider.tsx b/src/contexts/AuthProvider.tsx index a9712ce..05b78fd 100644 --- a/src/contexts/AuthProvider.tsx +++ b/src/contexts/AuthProvider.tsx @@ -112,6 +112,14 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { const completeSocialLogin = useCallback(async (accessToken: string) => { try { TokenService.setToken(accessToken); + try { + await auth.establishSession(); + } catch (sessionError) { + console.warn( + "Session cookie issuance failed after social login:", + sessionError, + ); + } const userData = await auth.getUser(); setUser(userData); setIsAuthenticated(true);