Relative Content

Tag Archive for node.jsnext.jsmiddlewarenext-authauth.js

The extended Next-Auth session does not show the new attributes inside Next.js middleware

I’m building a Next.js(14.2.5) web app with Auth.js (Next-auth ^5.0.0-beta.20) for authentication and Prisma (client version 5.18.0) as an ORM. I have extended the session to include 2 extra attributes: a list of roles of the authenticated user and a boolean “blocked” attribute. The problem is I also need access to those attributes in the middleware. Since I’m using Prisma I divided the NextAuth() initialization into two different files. Here is how it looks: