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?
#middleware.ts messing with Prisma.
14 messages · Page 1 of 1 (latest)
🔎 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)
bump
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
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 middleware
Weird, wish I knew this before choosing Prisma.
Anyway, I guess the workaround is my best bet at the moment.
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?