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)