Skip to content

Ensure trigger is set in JWT callback when update() is called#12919

Open
mbdevntc wants to merge 1 commit intonextauthjs:mainfrom
mbdevntc:patch-2
Open

Ensure trigger is set in JWT callback when update() is called#12919
mbdevntc wants to merge 1 commit intonextauthjs:mainfrom
mbdevntc:patch-2

Conversation

@mbdevntc
Copy link

☕️ Reasoning

When update() from the useSession() hook is called without any parameters, a GET request is sent (making its behavior similar to getSession()), instead of a POST request.
This prevents the trigger property (in JWT callback) from being set and used to determine whether the user session data needs to be re-fetched.

This is important when session data updates are handled inside the JWT callback and rely on the trigger value to determine whether user data should be re-fetched.

This PR ensures that a POST request is properly sent by defining the body property when needed.
Without setting the body, a GET request would be made, preventing the trigger property from being set in the JWT callback.
This is important when session data updates are handled inside the JWT callback and rely on the trigger value to determine whether user data should be re-fetched.
@mbdevntc mbdevntc requested a review from ThangHuuVu as a code owner April 28, 2025 13:03
@vercel
Copy link

vercel bot commented Apr 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 28, 2025 1:06pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Apr 28, 2025 1:06pm

@vercel
Copy link

vercel bot commented Apr 28, 2025

@mbdevntc is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@dBianchii
Copy link

Would really love to see this merged. It's affecting our team today

@dBianchii
Copy link

I applied this exact patch in my 5.0.0-beta.29 repo, and it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants