-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
getServerSession: [TypeError]: Cannot read properties of undefined (reading 'cookies') #7752
Comments
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
It was my mistake. I was trying to destruct the params and context separately. You have to destruct the params from the context itself. This is the right way to do it. 👇 export async function getServerSideProps(context: GetServerSidePropsContext) {
const session = await getServerSession(
context?.req,
context?.res,
authOptions
);
const { params } = context ?? {};
const { id } = params ?? {};
console.log(session);
console.log(id);
return {
props: {
id: id,
session: session,
},
};
} |
I'm still getting this issue: |
did you find the solution? |
This worked for me. |
Guys
Any progress? |
Guys I found the Answer so you dont have to pass context.req and context.res inside getServerSession. Only pass authOptions and it will work. Worked for me!!
|
The above worked for me, I was working with t3 stack, I finally switched ugh |
Environment
Describe the issue
I have this in the getServerSideProps. Basically, wants to get the session and pass it as props
But when I do this. I'm getting the below error.
How to reproduce
Expected behavior
It's supposed to return the session.
The text was updated successfully, but these errors were encountered: