-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
29 lines (28 loc) · 836 Bytes
/
auth.ts
File metadata and controls
29 lines (28 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// auth.ts
import NextAuth from "next-auth"
import Google from "next-auth/providers/google"
import { SupabaseAdapter } from "@auth/supabase-adapter"
export const { handlers, auth, signIn, signOut } = NextAuth({
debug: false, // Enable debugging to see exactly where it fails
providers: [
Google({
clientId: process.env.AUTH_GOOGLE_ID,
clientSecret: process.env.AUTH_GOOGLE_SECRET,
allowDangerousEmailAccountLinking: true,
}),
],
adapter: SupabaseAdapter({
url: process.env.NEXT_PUBLIC_SUPABASE_URL!,
// CRITICAL FIX: Must use the Service Role Key here
secret: process.env.SUPABASE_SECRET_KEY!,
}),
session: { strategy: "database" },
callbacks: {
session({ session, user }) {
if (session.user) {
session.user.id = user.id
}
return session
},
},
})