Replies: 1 comment 3 replies
-
@dgrcode did you manage to find a solution for this? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
EDIT: It looks like this issue #5008 is the source of the problems.
Question 💬
For some context, I'm using NextJS, Supabase (db hosting), Prisma, and NextAuth for authentication.
It seems like the Users are getting created properly in the database, but I don't see Sessions in the database. The frontend, however, is getting some session.
I've been investigating. What I've found is that the jwt token in the middleware is
null
. I've replaced:I've git-checked older commits where the middleware was working as expected. After git-checking I reseted the db and pushed the schema at that point in time with:
But I keep having the same problem. That makes me think the issue is not related with my code, but something must be funny with schemas/versions/dependencies or something like that.
Very funny stuff I just found out. I've setup the debugger with Nextjs, and I've added a breakpoint on "node_modules/next-auth/jwt/index.js", just inside the
getToken
function. Funny stuff:getToken
doesn't trigger the breakpoint 🧐getToken
from the page'sgetServerSideProps
do trigger the breakpoing.Very weird, but ok. I went and drilled down with "Step into" from the middleware call to
getToken
. It opens a differentindex.js
with exactly the same contents of "node_modules/next-auth/jwt/index.js", but VSCode can't locate the file in my computer (wat?).Anyways, the token is taken from the sessionStore, using the cookie named "next-auth.session-token". The value it gets looks like a JWT token, but it's broken.
Therefore the
_decode
call fails and the jwt becomesnull
in the middleware.Interestingly, the call to
getToken
that actually uses "node_modules" is able to successfully decode the broken token. As far as I know that couldn't be possible, so I'm completely clueless at this point.Open questions
Main questions are:
getToken
than the pages? (probably not next-auth related)getToken
called from the pages able to decode a broken token?Any help is greatly appreciated 🙏
How to reproduce ☕️
Not sure how to make a reproduction given the use of multiple env variables and supabase.
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions