From 1d65e3edc1fc1d3fa398ba0b1cd6ce960177093b Mon Sep 17 00:00:00 2001 From: inyoung Date: Fri, 14 Jun 2024 21:14:41 +0900 Subject: [PATCH 1/2] Fix: specify path as / to set cookie globally #297 --- src/api/axios.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/axios.ts b/src/api/axios.ts index 04ff80fd..efb4751c 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -34,8 +34,8 @@ instance.interceptors.response.use( }); if (tokenResponse.status === 200) { const { accessToken, refreshToken } = tokenResponse.data; - setCookie('accessToken', accessToken); - setCookie('refreshToken', refreshToken); + setCookie('accessToken', accessToken, { path: '/' }); + setCookie('refreshToken', refreshToken, { path: '/' }); axios.defaults.headers.common.Authorization = `${accessToken}`; originRequest.headers.Authorization = `${accessToken}`; return instance(originRequest); @@ -86,8 +86,8 @@ publicInstance.interceptors.response.use( }); if (tokenResponse.status === 200) { const { accessToken, refreshToken } = tokenResponse.data; - setCookie('accessToken', accessToken); - setCookie('refreshToken', refreshToken); + setCookie('accessToken', accessToken, { path: '/' }); + setCookie('refreshToken', refreshToken, { path: '/' }); axios.defaults.headers.common.Authorization = `${accessToken}`; originRequest.headers.Authorization = `${accessToken}`; return axios(originRequest); From a6d8172708669cd863cbc13df79512944a0a8fe0 Mon Sep 17 00:00:00 2001 From: inyoung Date: Sat, 15 Jun 2024 17:45:54 +0900 Subject: [PATCH 2/2] Feat: Add pathname to setCookie in stompcontext #297 --- src/contexts/StompContext.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contexts/StompContext.tsx b/src/contexts/StompContext.tsx index c0a4b2ff..0df7cf8b 100644 --- a/src/contexts/StompContext.tsx +++ b/src/contexts/StompContext.tsx @@ -68,8 +68,8 @@ export const StompProvider: React.FC<{ children: ReactNode }> = ({ }); if (tokenResponse.status === 200) { const { accessToken, refreshToken } = tokenResponse.data; - setCookie('accessToken', accessToken); - setCookie('refreshToken', refreshToken); + setCookie('accessToken', accessToken, { path: '/' }); + setCookie('refreshToken', refreshToken, { path: '/' }); connectChat(); } } catch (error) {