Prisma Client is not configured to run in the edge runtime
I am not using the edge runtime. I am using the
nodejs
runtime!
No Error:
Yes Error:
![No description](https://cdn.answeroverflow.com/1261374114480914523/image.png)
10 Replies
I had this same error (within NextJS) because I was trying to use the Prisma client within middleware, which does use the edge runtime. Maybe check that?
omg you're right
bruh I spend 5 hours on this LOL
I need better time management skills
thanks mate
I have a question, if I can't access the prisma client, and by extension
auth
, how am I supposed to know if the user is authenticated or not? This is how I used to do it:
But since I can't use the auth
function I have no idea how to get the user's session without using prisma client
Since I am using the prisma resolverI spent 3-4 hours on it myself and also came to ask a question here, hahaha
so honestly, I don’t know how you’re supposed to do it in middleware.
but you can do that await auth() call in any server component, and authenticate users that way
that’s what I’m doing; all my authentication/authorization is done within my React components
I’m still using Prisma with next-auth, I just literally have no middleware.ts file at all right now
after some digging I found this page:
https://www.prisma.io/docs/orm/overview/databases/postgresql
I followed the steps and looks like I don't get the error anymore. Looks like I could use the prisma client no problem in middleware now (as long as I don't directly make queries in the middleware)
However, I get a different error now:
Looks like one of the packages is using crypto somewhere. I'm not using the crypto module anywhere within my code
![No description](https://cdn.answeroverflow.com/1261660745251291220/image.png)
I also found an issue which is directly related to this:
https://github.com/brianc/node-postgres/issues/3206
GitHub
Doesn't work with next.js Edge runtime · Issue #3206 · brianc/node-...
I'm writing an app on next.js which I plan to deploy to CloudFlare Pages + Workers. I know there's CloudFlare support, but when running the local development server of next.js, I get the fo...
Looks like for now your solution is likely the best workaround at the moment. Would be nice to actually be able to use
middleware.ts
once this gets fixed thoughHahaha I swear you’re walking the exact same path as me
I bet you are using the “bcrypt” package to do Credentials authentication, right?
I also couldn’t get that to work; right now I’m just using Google for signin, was gonna come back to email/password later
yes!,
I am also using bcryptjs
Bcrypt imports the crypto package from node, which isn’t supported in edge runtime
I wasn’t running it in middleware but was still getting that error; I never tracked down exactly where it was getting called in Edge, I just ripped it out completely
Let me know if you figure out a good way to hash/store passwords, I still need to do that!
if I do, ill let you know