-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaks on webpack 5 #22
Comments
Isn't calling an endpoint a lot more time consuming than parsing a token? |
What do you mean? In the current implementation:
Assume that the token is valid and make your fetch request. 401 should occur only when the backend says so. Not necessarily when the token is expired (e.g. could be revoked). |
Here is a very basic implementation:
|
|
@magom001 Perhaps you could turn this into a PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently it uses node.js modules under the hood which are no longer bundled by webpack 5.
After going through the source code I believe the refresh strategy is not the best. Instead of checking the expiration time of the token on each request (parsing jwt is time consuming) one should check the response status for 401 status code or call a user provided callback to check if the token should be refreshed. Initiate a refresh if any condition is met. At the same time queue all the outgoing requests and also queue any request that was fired prior to the refresh and returned with 401 status.
The text was updated successfully, but these errors were encountered: