Sameer
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
Although, after the last message, I went ahead and rewrote the entire schema and auth configuration from scratch. I dropped all the data from the database for a clean start, and now it's working exactly how I wanted it to.
I'm not entirely sure, but I think it was a schema issue since I was using database-based sessions and not cookies. Nonetheless, thank you for helping! ❤️
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
Okay, it doesn't work. 🫠
For some reason, if we sign in for the first time, it works. However, if we sign out and then sign in with the same account, it doesn't do anything and returns false for !!auth?.user. Now, it doesn't work at all, not even the first time.
Codesandbox link
For some reason, installing dependencies in sandbox was failing continuesly.
here's the list of dependencies:
pnpm add @auth/drizzle-adapter @libsql/client drizzle-orm next-auth
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
I think, its working now
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
just auth
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
route.ts
removing runtime export don't seem to have any effect
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
Okay, I shifted from better-sqlite-3 to libSql from turso (which had edge compatible driver). Now that edge runtime error is resolved but no matter what how many times I login, it always redirect to
/login
route, and always return false for !!auth
.
middleware.ts
auth-config.ts
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
Question: Is this because, I am using SQLite (better-sqlite3) driver, which seems to not be in edge compatible driver.
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
I have seperated the auth config and the main auth file.
17 replies
DTDrizzle Team
•Created by Sameer on 12/29/2024 in #help
[Solved] Issues with Middleware and Authentication in NextAuth.js with Drizzle and SQLite
17 replies