middleware.ts messing with Prisma.
Unanswered
White Shepherd posted this in #help-forum
White ShepherdOP
Hello, I'm trying to make Prisma calls from my middleware.ts file, but i get errors from internal libraries, specifically the
node_modules/oidc-token-hash/lib/shake256.js module. I have a feeling it is because of the middleware running on the edge. I tried Prisma Accelerate which seems to work (i dont get any runtime errors), though I'd prefer to not use accelerate as it adds an extra layer of cost to my project, is there a way to make the middleware not run on the edge?13 Replies
White ShepherdOP
bump
@!=tgt I wish but nope
So, you either ditch Prisma or don't do calls in the middleware?
Yup. You must use Prisma Accelerate or use something else, Prisma doesn’t support the edge runtime
Damn
Cape May Warbler
How about moving the db call to a route handler and fetching the result in the middleware?
that is a valid workaround yes, though it's only a workaround at best. i would just use an edge-compatible database driver (e.g.
neondatabase/serverless if you are using neon) to query the database directly from middlewareWeird, wish I knew this before choosing Prisma.
Anyway, I guess the workaround is my best bet at the moment.
@joulev that is a valid workaround yes, though it's only a workaround at best. i would just use an edge-compatible database driver (e.g. `neondatabase/serverless` if you are using neon) to query the database directly from middleware
Can you link me to a place I can see all the edge-compatible options I would have?
@GetPsyched Can you link me to a place I can see all the edge-compatible options I would have?
I don’t have one, sorry
No worries, any personal recommendations?
Other than neon which you already suggested, of course