Error validating datasource `db`: the URL must start with the protocol `prisma://`
Hello everyone!
Im currently getting this problem that i descriped in the title. where when i try to run Prisma on cloudflare workers
i tried the soultion from here "https://www.prisma.io/docs/orm/reference/prisma-client-reference#programmatically-override-a-datasource-url"
but cant seem to get it to work
.dev.vars
DATABASE_URL="DATABASE_URL=postgresql://postgres:@localhost:5432/postgres?schema=test"
this is my prisma client
my schema.prisma
and when i try to add "prisma://" in the front it says "api key needed"Prisma Client API | Prisma Documentation
API reference documentation for Prisma Client.
10 Replies
hmm I don't think that will work.
DATABASE_URL="DATABASE_URL=postgresql://postgres:@localhost:5432/postgres?schema=test"
isn't a valid string, it should just be something like DATABASE_URL=postgresql://postgres:@localhost:5432/postgres?schema=test
but even then, there is no PostgreSQL database hosted at localhost on cloudflare workers.
This documentation (specific to Cloudflare) might help.Deploy to Cloudflare Workers & Pages | Prisma Documentation
Learn the things you need to know in order to deploy an app that uses Prisma Client for talking to a database to a Cloudflare Worker or to Cloudflare Pages.
Hey i done this and still dont work i still get "the URL must start with the protocol
prisma://
"
i did prisma generate also
im trying to set it up locally first or is that not going to work at all?
i have now tried this way aswell
and then i tried to call it in my router like this
im using cloudflare workers + hono btw
also updated the
db that i export like this
This is happening locally? What command are you running to start your app? What version of
@prisma/client
are you using?@Jon Harrell
To start it
wrangler dev src/index.ts
and "@prisma/client": "5.12.1",
i think im just going to use cloudflare d1That will work a lot better. I'm not sure if there's a way to test a local DB against wrangler.
Some will work: https://developers.cloudflare.com/workers/databases/connecting-to-databases/
but in general, I'd say that D1 will be the most straightforward 🙂
Cloudflare Docs
Connect to databases · Cloudflare Workers docs
Learn about the different kinds of database integrations Cloudflare supports.
Alright thank you so much!
Hello @Jon Harrell,
I'm having the same issue error 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?
I'm new on Discord. Used the search bar to find this post. Wasn't sure if I'm supposed to continue the discussion here or start a new post.
Start a new one, please 🙂