mirror of
https://github.com/dyzulk/trustlab.git
synced 2026-01-27 15:11:57 +07:00
fix: stop 401 auth retry loop and remove unsafe PNA localhost fallback
This commit is contained in:
@@ -13,7 +13,22 @@ export const useAuth = ({ middleware, redirectIfAuthenticated }: { middleware?:
|
||||
.catch(error => {
|
||||
if (error.response.status !== 409) throw error;
|
||||
router.push('/verify-email');
|
||||
})
|
||||
}),
|
||||
{
|
||||
onErrorRetry: (error, key, config, revalidate, { retryCount }) => {
|
||||
// Never retry on 401 Unauthorized
|
||||
if (error.response?.status === 401) return;
|
||||
|
||||
// Never retry on 409 Conflict (handled by catch block above)
|
||||
if (error.response?.status === 409) return;
|
||||
|
||||
// Only retry up to 3 times for other errors
|
||||
if (retryCount >= 3) return;
|
||||
|
||||
// Retry after 5 seconds
|
||||
setTimeout(() => revalidate({ retryCount }), 5000);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const csrf = () => axios.get('/sanctum/csrf-cookie');
|
||||
|
||||
Reference in New Issue
Block a user