From 75bbd9af0a53d2ef169ef6f61a32ff7223a79f2f Mon Sep 17 00:00:00 2001 From: bkellam Date: Sun, 2 Nov 2025 13:57:21 -0800 Subject: [PATCH] Use DATABASE_URL env in web prisma.ts --- packages/web/src/prisma.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/web/src/prisma.ts b/packages/web/src/prisma.ts index d9e488ce..50eb11af 100644 --- a/packages/web/src/prisma.ts +++ b/packages/web/src/prisma.ts @@ -13,7 +13,17 @@ const globalForPrisma = globalThis as unknown as { prisma: PrismaClient } // @todo: we can mark this as `__unsafePrisma` in the future once we've migrated // all of the actions & queries to use the userScopedPrismaClientExtension to avoid // accidental misuse. -export const prisma = globalForPrisma.prisma || new PrismaClient() +export const prisma = globalForPrisma.prisma || new PrismaClient({ + // @note: even though DATABASE_URL is of type string, we need to check if it's defined + // because this code will be executed at build time, and env.DATABASE_URL will be undefined. + ...(env.DATABASE_URL ? { + datasources: { + db: { + url: env.DATABASE_URL, + }, + } + } : {}) +}) if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma /**