You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that next-auth can't be used inside getServerSideProps functions, when using next-auth v5 beta with Nextjs v14.
Using auth(ctx) inside getServerSideProps yields the following error:
Login with the credentials username admin, password admin
After successful authentication, you'll be redirected to http://localhost3000 where we attempt to load the session inside a getServerSideProps function. You'll see the error being thrown.
Expected behavior
We'd expect the auth function created through the NextAuth function to work as defined in the docs on how to use next-auth v5, where inside SSR within Next.js one should be able to call await auth(getServerSidePropsContext) to retrieve the session.
The text was updated successfully, but these errors were encountered:
trm217
added
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
Nov 11, 2024
Environment
Reproduction URL
https://github.com/trm217/next-auth-v5beta--nextjs-ssr-bug
Describe the issue
I found that next-auth can't be used inside getServerSideProps functions, when using next-auth v5 beta with Nextjs v14.
Using
auth(ctx)
inside getServerSideProps yields the following error:Code that causes this error:
How to reproduce
npx auth secret
npm run dev
https://localhost:3000
http://localhost3000
where we attempt to load the session inside a getServerSideProps function. You'll see the error being thrown.Expected behavior
We'd expect the auth function created through the NextAuth function to work as defined in the docs on how to use next-auth v5, where inside SSR within Next.js one should be able to call
await auth(getServerSidePropsContext)
to retrieve the session.https://authjs.dev/getting-started/migrating-to-v5 under authentication methods
The text was updated successfully, but these errors were encountered: