From bd4168c55d70f7e090888c161edfb76e71993fe3 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 16 Feb 2025 17:06:27 -0800 Subject: [PATCH] fix: use postgres_url provided by supabase/vercel config instead of database_url --- db/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/index.ts b/db/index.ts index 888821269e..3edd346a4f 100644 --- a/db/index.ts +++ b/db/index.ts @@ -1,8 +1,13 @@ import { drizzle } from 'drizzle-orm/postgres-js' import postgres from 'postgres' -const connectionString = process.env.DATABASE_URL! +// In production, use the Vercel-generated POSTGRES_URL +// In development, use the direct DATABASE_URL +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 }) +const client = postgres(connectionString, { + prepare: false, + ssl: process.env.NODE_ENV === 'production', +}) export const db = drizzle(client)