Refresh Token Rotation with NextJs
Hey everyone! We have been using
better-fetch
with a custom auth plugin to handle attaching a bearer token to each request to our backend, and it's working great. However, I was wondering if anyone has had to deal with setting up a refresh token rotation within a plugin? For example, if the request fails with a 401
status, how can I trigger only 1 call to my /refresh
endpoint without race conditions to refresh the token and retry the request with the new token?
Also, a related question is how would I sign out the user on the client if the refresh token was revoked / something else went wrong?
Here's my current implementation (not working)
0 Replies