fix: use postgres_url provided by supabase/vercel config instead of database_url

This commit is contained in:
Waleed Latif
2025-02-16 17:06:34 -08:00
parent 9201e783f2
commit bd4168c55d
+7 -2
View File
@@ -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)