#authjs session not working with middleware

10 messages · Page 1 of 1 (latest)

prisma sun
#

When setting custom properties and calling the session in any page using auth()
function it works just fine but when accessed using req.auth.user property
all the set properties of user object that were set using jwt token becomes undefined even though typescript recognizes it

solemn groveBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

prisma sun
#

authjs session not working with middleware

twilit jungle
#

Do you set the custom probs via database query that maybe doesnt work on edge?

prisma sun
#

database call

#

in the jwt call back

#

then from that to session

#

but i just figured that middleware runs before auth.ts
but still dont understand how it has the 3 values, name email and image

#

even id is undefined

#

so for now the workaround i have is to call in layout itself