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!
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.