Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auto-refresh): override callback result headers/cookies if the r…
…esult is a response In the instance where a user is using withAuth with the callback pattern, we can't just return the result of their callback directly - we need to be returning our response with our (possibly refreshed) tokens. An initial workaround was just to invoke onSuccess and ignore whatever the user returned and return our response. This could be breaking if the user returned their own response. This implementation checks to see if the user has returned their own response from the callback - if so, we merge our responses cookies and headers into it, then return it. This way we: - Preserve the user response - Still pass down our refreshed tokens immediately Note: If we have conflicting headers or cookie names, this does technically override them favouring ours - which is fine, I think.
- Loading branch information