Switch from SuperTokens to NextAuth.js

BREAKING CHANGE: Replace SuperTokens with NextAuth.js

Why:
- SuperTokens had persistent Traefik routing issues
- SSL certificate not issuing correctly
- Complex infrastructure (separate container)
- NextAuth runs in Next.js app (simpler, no separate service)

Changes:
- Install next-auth, @auth/prisma-adapter, prisma
- Create NextAuth API route: app/api/auth/[...nextauth]/route.ts
- Add Prisma schema for NextAuth tables (users, sessions, accounts)
- Update auth page to use NextAuth signIn()
- Remove all SuperTokens code and dependencies
- Keep same Google OAuth (just simpler integration)

Benefits:
- No separate auth service needed
- No Traefik routing issues
- Sessions stored in Montreal PostgreSQL
- Simpler configuration
- Battle-tested, widely used

All authentication data stays in Montreal!

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-17 15:12:21 -08:00
parent 8cd95607a4
commit bbb22f1c37
12 changed files with 534 additions and 632 deletions

View File

@@ -4,9 +4,10 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "prisma generate && prisma db push --accept-data-loss && next build",
"start": "next start",
"lint": "eslint",
"postinstall": "prisma generate",
"test:db": "tsx scripts/test-alloydb.ts",
"migrate:postgres": "tsx scripts/migrate-from-postgres.ts",
"migrate:reassign": "tsx scripts/reassign-migrated-data.ts",
@@ -18,6 +19,8 @@
"mcp:server": "node mcp-server.js"
},
"dependencies": {
"@auth/core": "^0.34.3",
"@auth/prisma-adapter": "^2.11.1",
"@google-cloud/vertexai": "^1.10.0",
"@google/genai": "^1.30.0",
"@google/generative-ai": "^0.24.1",
@@ -41,14 +44,12 @@
"google-auth-library": "^10.5.0",
"lucide-react": "^0.553.0",
"next": "16.0.1",
"next-auth": "^4.24.13",
"next-themes": "^0.4.6",
"pg": "^8.16.3",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"sonner": "^2.0.7",
"supertokens-auth-react": "^0.51.2",
"supertokens-node": "^24.0.1",
"supertokens-web-js": "^0.16.0",
"tailwind-merge": "^3.4.0",
"tsx": "^4.20.6",
"uuid": "^13.0.0",
@@ -56,6 +57,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@prisma/client": "^5.22.0",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
@@ -64,6 +66,7 @@
"eslint-config-next": "16.0.1",
"firebase-admin": "^13.6.0",
"firebase-functions": "^7.0.0",
"prisma": "^5.22.0",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
"typescript": "^5"