value of getSession is null in getServerSideProps and getInitialProps #1693
Unanswered
Industrial
asked this question in
Help
Replies: 2 comments
-
You can create a |
Beta Was this translation helpful? Give feedback.
0 replies
-
I am not entirely sure why you expected a session object. You must log in with one of the providers to see it. I just did what you said to reproduce, but I got the user |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
When I clone the example project from https://github.com/nextauthjs/next-auth-example and start the server and go to the
/server
route, the session variable isnull
.Steps to reproduce
Now go to https://github.com/nextauthjs/next-auth-example/blob/main/pages/_app.js#L7 and add a
console.log(pageProps.session)
.Now open the browser and visit http://localhost:3000/server
Expected behavior
A session object.
Screenshots or error logs
Server:
Client:
Additional context
Currently having problems logging in so I only checked the logged case in this app but it does the same (
null
) in my own app while logged in.I also tried replacing the getServerSideProps with getInitialProps (because of https://nextjs.org/docs/advanced-features/custom-app#caveats)
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
Beta Was this translation helpful? Give feedback.
All reactions