Are you able to see the network request details
[SOLVED] user session is created, but `currentUser` still returns null
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
this?
No the account.get() call
Is it the last session cookie that came from Appwrite?
Rank 3: Container
it gets called on page load by the middleware. so can't specify it from the console
Rank 3: Container
what do u mean by the last session cookie?
The last time you created the email session.
Rank 3: Container
maybe i'm too noob to understand what u saying. do u want me to remove the middleware code and do a successful login, and then again add the middleware code and then compare the before and after cookie values?
Sure that could work.
Or you can manually try to use that cookie value to make the request
Rank 3: Container
yoo... they aren't same😐
That's not good. Maybe the value in your middleware is an old deleted session and that's why you're getting the error
Rank 3: Container
sad... how can i solve this?
Are you making sure to clear things as necessary?
Rank 3: Container
clear things as necessary? didn't get it
For example, deleting the cookie if it's not valid anymore
Rank 3: Container
i'm deleting the cookies only when the user logs out. do i need to do anything more?
Maybe it's not getting deleted in all places or something. I don't know. I hate nextjs
Rank 3: Container
after some digging, i found that when the middleware is on, we are not setting any new cookie value. till now what i was seeing was the cookie from the last session
Again...I hate nextjs 🤣
Rank 3: Container
and after your suggestion on another post of mine, i handled the cookies manually in the /auth/oauth2/success path
Rank 3: Container
that means my middleware is redirecting it from /auth/oauth2/success to / before the code of /auth/oauth2/success gets executed
Rank 3: Container
okay, so I just found out I'm nothing but dumb. i had to add /auth/oauth2/success as a public route in the middleware
Rank 3: Container
don't hate nextjs. hate me🙂
Rank 3: Container
[SOLVED] user session is created, but currentUser still returns null
Still hate nextjs because of all these gotchas 😜 I'm glad you figured it out 