Context is not being passed correctly
I will include my setup at the end. My problem is that I am using nextauth with database sessions and passing the session as context into the procedures; however, everything that I have added myself isn't being included in the context for some reason (user.id and user.role)
This is my session type I declared,
This is the session callback I am using.
The console.log is just to see what is happening where (I will include it at the end)
I will include the rest of the information in the next message as I reached the character limit.
1 Reply
Finally this is what is creating the session.
What is happening is that when the front end calls the session I properly get the role inside session.user.role.
Moving from the front end to the actual API calls, the first time it creates the session in the middleware it is going through my session callback, and the session when logged DOES come with role and userId,
However once it is returned it somehow loses those two values, and the context is set without those two.
Any help is much appreciated thanks in advance.
Setup:
T3: Nextauth, Nextjs pages router, trpc, typescript and prisma.
Node version: 18.18.1