Middleware error: PrismaClientKnownRequestError

On localhost it works all fine no error, nothing, but on vercel there is this issue "Middleware error: PrismaClientKnownRequestError: Invalid prisma.subdomain.findFirst() invocation: Error validating datasource db: the URL must start with the protocol prisma://" i dont know why, my env is DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=..." DIRECT_DATABASE_URL="postgres://avnadmin:...pg-236b6581-....k.aivencloud.com:14028/defaultdb?sslmode=require" My prisma.ts is
import { PrismaClient } from "@prisma/client/edge";
// test
import { withAccelerate } from "@prisma/extension-accelerate";

// Learn more about instantiating PrismaClient in Next.js here: https://www.prisma.io/docs/data-platform/accelerate/getting-started

const prismaClientSingleton = () => {
return new PrismaClient().$extends(withAccelerate());
};

declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
import { PrismaClient } from "@prisma/client/edge";
// test
import { withAccelerate } from "@prisma/extension-accelerate";

// Learn more about instantiating PrismaClient in Next.js here: https://www.prisma.io/docs/data-platform/accelerate/getting-started

const prismaClientSingleton = () => {
return new PrismaClient().$extends(withAccelerate());
};

declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
and finally my schema.prisma
generator client {
provider = "prisma-client-js"
engineType = "library"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
engineType = "library"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
so i do not get what the issue is as i have followed all the docs and tried for hour's and it just doesn't seem to wanna work. if anyone could help tat would be amazing
4 Replies
fuzzbear
fuzzbearOP3w ago
?
RaphaelEtim
RaphaelEtim3w ago
Hi @fuzzbear What happens when you change the import from import { PrismaClient } from "@prisma/client/edge" to import { PrismaClient } from "@prisma/client
fuzzbear
fuzzbearOP3w ago
hey @RaphaelEtim thank's alot i have fixed it now, the issue was with my ENV on vercel.
RaphaelEtim
RaphaelEtim3w ago
Good to hear it's fixed now.
Want results from more Discord servers?
Add your server