Skip to content

Commit

Permalink
Merge pull request #78 from Tea-Bliss/feature/72_리펙토링
Browse files Browse the repository at this point in the history
[hotfix] axios 인터셉터 주석처리
  • Loading branch information
smb0123 authored Jun 24, 2024
2 parents 41be905 + bc2f1fa commit 0a47ae7
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/apis/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ axiosInstance.interceptors.request.use(
}
);

axiosInstance.interceptors.response.use(
(response) => {
// 응답이 성공적이면 그대로 응답 반환
return response;
},
async (error) => {
if (error.response.status === 401) {
try {
// re-issue 엔드포인트를 호출하여 새로운 토큰을 가져옴
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}member/re-issue`, {
headers: {
'Content-type': 'application/json',
Authorization: `${localStorage.getItem('token')}`,
},
});
// axiosInstance.interceptors.response.use(
// (response) => {
// // 응답이 성공적이면 그대로 응답 반환
// return response;
// },
// async (error) => {
// if (error.response.status === 401) {
// try {
// // re-issue 엔드포인트를 호출하여 새로운 토큰을 가져옴
// const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}member/re-issue`, {
// headers: {
// 'Content-type': 'application/json',
// Authorization: `${localStorage.getItem('token')}`,
// },
// });

if (response.status === 200) {
const newToken = response.headers.authorization;
localStorage.setItem('token', newToken);
}
} catch (err) {
const router = useRouter();
router.push(ROUTE.HOME);
}
}
// if (response.status === 200) {
// const newToken = response.headers.authorization;
// localStorage.setItem('token', newToken);
// }
// } catch (err) {
// const router = useRouter();
// router.push(ROUTE.HOME);
// }
// }

return Promise.reject(error);
}
);
// return Promise.reject(error);
// }
// );

0 comments on commit 0a47ae7

Please sign in to comment.