Relative Content

Tag Archive for typescriptnext.jsnext-auth

Nextjs middleware file is not executing anything

Okay so I was working with NextJs implementing NextAuth for a page that’s supposed to be accessed by admin only. Then, I was introduced to the new concept of the “middleware.ts” file, which apparently should execute a function for every determined route.
But it is not working for me for some reason, check this out, I removed everything, and only kept a small console log just to know if the file is running, but it doesn’t seem to log anything to the browser inspect or the terminal.

Error while extending session in AuthJS v5

I’ve been working on extending the session in authjs v5 using callbacks to implement role-based authorization. I aim to assign a role to the token generated and then pass it to the session. The role is defined in the User Model in Prisma Schema as an enum with values user or admin.
Here is the relevant code from my auth.ts file: