api.auth.getSession returns null
Better auth team.
Can you fix this issue?
This is really bugging my application.
https://github.com/better-auth/better-auth/issues/2055
GitHub
auth.api.getSession returns null in RSC Layout.tsx with valid sessi...
Is this suited for github? Yes, this is suited for github To Reproduce I'm trying to debug why auth.api.getSession will return null, when the session is valid after a query to /api/auth/get-ses...
4 Replies
Hey there is too many variables in that issue to confirm that you're facing the exact same thing they are - it's too broad.
Mind providing details of your own?
Where are you calling the getSession, what framework, what version, etc.
I am using next.js app router v15.4.3 and better-auth v1.3.2
Here is my auth.ts
This is my middleware
Middleware check is passed, but when I call this function to get session
This returns null.
cc: @Ping
It's possible that the session has expired, so you're holding on to an out-dated cookie.
@Ping Should I check session is expired on middleware also then?
We set the session's expiresIn to 7 days.
But we see this error too often.
https://github.com/masumi-network/sokosumi/blob/main/web-app/src/lib/auth/auth.ts
I normally get this error, when I log in.