Synchronization Issue Between next-auth Session and useSWR Fetching #3059
Unanswered
Johncena-Huang
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Title: Synchronization Issue Between
next-auth
Session anduseSWR
FetchingDescription:
I’m using
next-auth
withuseSWR
for data fetching, and I'm trying to set up an Axios interceptor to add an Authorization token to the request headers. However, I’m encountering a synchronization issue whereuseSWR
is firing before I reset the axios interceptor.Steps to Reproduce:
useSWR
to fetch data with Axios.Authorization
header with the token fromnext-auth
'suseSession()
.useSWR
is called before the axios interceptor is reset.Code Example:
Global setup
My fetcher
How the fetcher is used
Expected Behavior:
when useSWR calls the fetcher, axios instance interceptor should already be synchronized with useSession.
Environment:
Beta Was this translation helpful? Give feedback.
All reactions