#middleware.ts messing with Prisma.

14 messages · Page 1 of 1 (latest)

turbid zenith
#

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?

light plazaBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

turbid zenith
#

bump

restive flicker
foggy forge
#

Yup. You must use Prisma Accelerate or use something else, Prisma doesn’t support the edge runtime

restive flicker
#

Damn

earnest jasper
#

How about moving the db call to a route handler and fetching the result in the middleware?

foggy forge
#

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

restive flicker
#

Weird, wish I knew this before choosing Prisma.

#

Anyway, I guess the workaround is my best bet at the moment.

restive flicker
restive flicker
#

No worries, any personal recommendations?