Context on middleware always undefined
I'm trying to use trpc with next-auth using the GoogleProvider. I can sign in just fine,
publicProcedures
work, but all protectedProcedures
will throw UNAUTHORIZED
, even though when using the useSession
hook on the same component, it returns the correct data.
I can also see the session on prisma studio.
3 Replies
If I comment the check for a session, I can confirm it is passed down correctly to my mutation which uses the
protectedProcedure
.
Also, changing the check for if (typeof ctx === "undefined") {
will throw the UNAUTHORIZED error.Hey, I'm having the same issue on my project and it was working fine two weeks ago.
The last significant change that I've made was to update Prisma from 5.1.1 to 5.3.1. I've downgrade it but it was not related.
I've tried to change the provider from Google to Github but still the same error. Did you manage to find out a solution?
Not really, I ended up not using the middleware and checking for the session data with the public procedure.