diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c8e6c966..9e99e260 100755 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -88,6 +88,15 @@ function App() { }, }), defaultOptions: { + queries: { + retry: (failureCount, error) => { + if (axios.isAxiosError(error) && error.response?.status === 401) { + return false; + } + + return failureCount < 3; + }, + }, mutations: { onError: handleError, }, diff --git a/frontend/src/hooks/api/user.ts b/frontend/src/hooks/api/user.ts index f4b99026..cf673868 100644 --- a/frontend/src/hooks/api/user.ts +++ b/frontend/src/hooks/api/user.ts @@ -14,14 +14,11 @@ export const useGetUserQuery = () => { const dispatch = useDispatch(); const authStore = useSelector(selectAuth); - if (authStore.accessToken) { - axios.defaults.headers.common["Authorization"] = `Bearer ${authStore.accessToken}`; - } - const query = useQuery({ queryKey: generateGetUserQueryKey(authStore.accessToken || ""), enabled: Boolean(authStore.accessToken), queryFn: async () => { + axios.defaults.headers.common["Authorization"] = `Bearer ${authStore.accessToken}`; const res = await axios.get("/users"); return res.data; },