-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(ts): improve unstable_getServerSession
return type
#5792
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
🎉 Experimental release published 📦️ on npm! pnpm add next-auth@0.0.0-pr.5792.9119ea67 yarn add next-auth@0.0.0-pr.5792.9119ea67 npm i next-auth@0.0.0-pr.5792.9119ea67 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this approach, save us from exposing another API! 👍 Added 2 comments
Co-authored-by: Thang Vu <hi@thvu.dev>
@@ -143,7 +153,7 @@ export async function unstable_getServerSession( | |||
} else { | |||
req = args[0] | |||
res = args[1] | |||
options = args[2] | |||
options = Object.assign(args[2], { providers: [] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that we are modifying args[2]
here? I recently updated next-auth and started getting some odd behavior where I've got places in my app using my authOptions
object and it's fine at first, but eventually the providers got cleared out...this is the reason for that.
I suspect we meant to do options = Object.assign({}, args[2], { providers: [] })
instead? Or IMO use the spread operator options = { ...args[2], providers: [] }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened a PR that should fix this.
Currently,
unstable_getServerSession
assumes that it always returns aSession
. However, in practice, it should match thesession
callback's return type. This can be used to create feature parity withgetToken
like this:This is an alternative to #5791, reducing the number of APIs needed in the future (no need for
getToken
). (See #5791 (comment))Closes #5791, fixes #5754