[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
Hi,
I'm working with NextAuth (Auth.js) and Drizzle for the first time. I've successfully implemented OAuth for Google and GitHub, and I added the DrizzleAdapter and schema by following the NextAuth documentation.
Now, I want to set up middleware to differentiate between protected and public routes based on whether the user is logged in. However, I'm running into a couple of issues:
1. The middleware check never seems to run. 2. !!auth?.user always returns false, even when the user is logged in.
I've tried using the
authorized
authorized
method in the callbacks within
NextAuthConfig
NextAuthConfig
. I’ve also watched a few YouTube videos, but for some reason, their approaches don't seem to work for me.
I’m not sure what I might be doing wrong. Any guidance would be greatly helpfull!