Eden1711/axios-auth-refresh: Bulletproof Axios Interceptor for JWT Refresh Token
github.comΒ·5dΒ·
Discuss: DEV
πŸ”ŒAPIs
Preview
Report Post

Axios Auth Refresh Queue πŸ›‘οΈ

πŸš€ Ultra-lightweight (< 1KB) zero-dependency authentication interceptor for Axios.

A bulletproof, zero-config Axios interceptor that handles JWT refresh tokens automatically. It solves the race condition problem when multiple requests fail with 401 Unauthorized simultaneously.

License

MIT

πŸš€ Why use this?

When your Access Token expires, your app might fire 5 API requests at once. Without this library, all 5 will fail, leading to 5 separate "Refresh Token" calls (Race Condition) or forcing the user to logout.

This library fixes it by:

  1. Intercepting the first 401 error.
  2. Pausing all other requests in a Queue.
  3. Calling the "Refresh Token" …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help