Error validating datasource URL must start with the protocol prisma://

Hello, I'm having this issue when deploying my Next application to Vercel. Everything works fine locally. I have triple-checked env variables on Vercel and they're the same as my env locally. I also get this error if I build the project and run prod environment locally without deploying to Vercel. Any idea what might cause this; and how to solve it?
No description
6 Replies
Aladin El-Khalil
@Jon Harrell Here you go, a new post, thanks for the help in advance!
Nurul
Nurul3w ago
Hey @Aladin El-Khalil Are you using Prisma Accelerate? How are you generating your PrismaClient? Can you share your build command with us?
Aladin El-Khalil
Hi @Nurul (Prisma) I'm generating with the command npx prisma generate --no-engine My full build command on Vercel is next build && npx prisma generate --no-engine I'm not using accelerate, it's commented out. This is my prisma client.
import { PrismaClient } from "@prisma/client";
// import { withAccelerate } from "@prisma/extension-accelerate";

const createAcceleratedPrismaClient = () => {
return new PrismaClient({
log:
process.env.NODE_ENV === "development"
? // ? ["query", "error", "warn"]
["error", "warn"]
: ["error"],
});
// .$extends(withAccelerate());
};

type PrismaClientAccelerated = ReturnType<typeof createAcceleratedPrismaClient>;

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientAccelerated | undefined;
};

let prisma = globalForPrisma.prisma ?? createAcceleratedPrismaClient();

if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma;
}

export default prisma;
import { PrismaClient } from "@prisma/client";
// import { withAccelerate } from "@prisma/extension-accelerate";

const createAcceleratedPrismaClient = () => {
return new PrismaClient({
log:
process.env.NODE_ENV === "development"
? // ? ["query", "error", "warn"]
["error", "warn"]
: ["error"],
});
// .$extends(withAccelerate());
};

type PrismaClientAccelerated = ReturnType<typeof createAcceleratedPrismaClient>;

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientAccelerated | undefined;
};

let prisma = globalForPrisma.prisma ?? createAcceleratedPrismaClient();

if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma;
}

export default prisma;
Nurul
Nurul3w ago
Can you remove the --no-engine flag and try again?
Aladin El-Khalil
Yes I'll try I think that solved the problem. Why did that help @Nurul (Prisma) ? I recall that the cli build command encourages the use of --no-engine in production, that's confusing then? @Nurul (Prisma)
Nurul
Nurul3w ago
The --no-engine flag generates Prisma Client without an accompanied engine for use with Prisma Accelerate. In your code, as you had commented out Accelerate extension and using a direct database connection string, the --no-engine flag shouldn't be used.
Want results from more Discord servers?
Add your server