From 3b1788a469b2d7fc2687c9a9e9058f57b1f330f0 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 16 Feb 2025 17:28:36 -0800 Subject: [PATCH] fix(auth): remove ssl enforcement in prod for supabase db --- db/index.ts | 1 - lib/auth.ts | 35 ++++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/db/index.ts b/db/index.ts index 3edd346a4f..974984d81e 100644 --- a/db/index.ts +++ b/db/index.ts @@ -8,6 +8,5 @@ const connectionString = process.env.POSTGRES_URL || process.env.DATABASE_URL! // Disable prefetch as it is not supported for "Transaction" pool mode const client = postgres(connectionString, { prepare: false, - ssl: process.env.NODE_ENV === 'production', }) export const db = drizzle(client) diff --git a/lib/auth.ts b/lib/auth.ts index 4a41e0f75e..12cfaf6593 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -25,19 +25,6 @@ export const auth = betterAuth({ emailAndPassword: { enabled: true, requireEmailVerification: true, - sendVerificationEmail: async ({ user, url }: EmailHandler) => { - await resend.emails.send({ - from: 'Sim Studio ', - to: user.email, - subject: 'Verify your email', - html: ` -

Welcome to Sim Studio!

-

Click the link below to verify your email:

- ${url} -

If you didn't create an account, you can safely ignore this email.

- `, - }) - }, sendResetPassword: async ({ user, url }: EmailHandler) => { await resend.emails.send({ from: 'Sim Studio ', @@ -52,6 +39,28 @@ export const auth = betterAuth({ }) }, }, + emailVerification: { + sendVerificationEmail: async ({ user, url }: EmailHandler) => { + console.log('Attempting to send verification email to:', user.email) + console.log('Verification URL:', url) + try { + const result = await resend.emails.send({ + from: 'Sim Studio ', + to: user.email, + subject: 'Verify your email', + html: ` +

Welcome to Sim Studio!

+

Click the link below to verify your email:

+ ${url} +

If you didn't create an account, you can safely ignore this email.

+ `, + }) + console.log('Resend API response:', result) + } catch (error) { + console.error('Error sending verification email:', error) + } + }, + }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!,