-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
User is null in nextjs api route handler #802
Comments
Have you checked out this article? |
@j4w8n Hmmm. It does make sense logically but there should be an easier way to do this instead of manually adding the cookies on each call. Can the middleware not do this? |
I'm not familiar with Next, I just recall someone having a similar issue in the Discord community. |
@j4w8n I will keep this open in the hope that there is an easier solution since the blog post is almost a year old. |
Can confirm that adding
|
Bug report
Describe the bug
I have set up auth with google in my project and it is working fine. I have set up the middleware and all the
createClient
functions for server and client. I have the correct auth state in both the server and the client.But in API route handlers, I get user as null even though I am logged in.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
ssr
package.getSession()
Expected behavior
I should get the session info of the current user.
System information
Additional context
I think the problem is happening because cookies are not being passed to the route handler. But I think they should be passed automatically through the middleware. Why is that not happening?
The text was updated successfully, but these errors were encountered: