---
title: "Comment by Oussama Moutafatin on \"Authentication & Refresh token flow with Nextjs, Typescript, React Query and axios interceptors.\" | Hashnode"
description: "The try-catch inside the interceptor does not catch anything, the interceptor keeps looping within itself"
url: "https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/6450b2227a00e1d8014fb910"
---

[Discussion](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930)

Comment [Authentication & Refresh token flow with Nextjs, Typescript, React Query and axios interceptors.](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930)

[Oussama Moutafatin](https://hashnode.com/@moutafatin)

[May 2, 2023](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/6450b2227a00e1d8014fb910)

The try-catch inside the interceptor does not catch anything, the interceptor keeps looping within itself

[K Srinivas Rao](https://hashnode.com/@srini53168)

[Sep 4, 2023](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/6450b2227a00e1d8014fb910#reply-64f5f23ef6310e9375f9638c)

Hey,

I'll be writing a series of articles on production grade authentication which is going to cover everything in depth with the latest tools and patterns, stay tuned!

[mohammad garmabi](https://hashnode.com/@garmabi07)

[Nov 15](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/6450b2227a00e1d8014fb910#reply-6af9aee68467285acb025583)

The loop usually happens because the /refresh call goes through the same axios instance and hits the same 401 handler. Two fixes: use a separate axios instance (or a skipAuthRefresh flag) for the refresh request, and mark the original request with \_retry = true so it's only replayed once. If the refresh itself fails, reject the queued promises and log out instead of retrying.
