Skip to content

Commit

Permalink
Fix: specify path as / to set cookie globally #297
Browse files Browse the repository at this point in the history
  • Loading branch information
rmdnps10 committed Jun 14, 2024
1 parent 401de36 commit 1d65e3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1d65e3e

Please sign in to comment.