Skip to content

Commit

Permalink
fix: refresh token infinite try error
Browse files Browse the repository at this point in the history
  • Loading branch information
2paperstar committed Jun 6, 2024
1 parent 0ab904e commit 0ee4fe6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ api.interceptors.response.use(
(response) => response,
async (error) => {
const originalRequest = error.config;
if (error.response?.status === 401 && !originalRequest._retry) {
if (error.response?.status === 401) {
if (originalRequest._retry || originalRequest.url === '/auth/refresh') {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
return Promise.reject(error);
}
originalRequest._retry = true;
const refreshToken = localStorage.getItem('refreshToken');
if (!refreshToken) {
Expand Down

0 comments on commit 0ee4fe6

Please sign in to comment.