Nextjs edge middleware: Cannot import node:crypto

Vercel Github discussion with other users having the same problem using Drizzle: https://github.com/vercel/next.js/discussions/47314 Hello, it seems that Drizzle is attempting to import node/crypto and failing inside nextjs edge middleware functions. However, using the crypto global in edge functions/middleware is supported ๐Ÿ‘ https://github.com/vercel/examples/blob/main/edge-middleware/crypto/middleware.ts https://vercel.com/templates/next.js/edge-functions-crypto Is it possible to add support for nextjs edge middleware or are there any available workarounds?
GitHub
Cannot import node:crypto in middleware.ts (placed in root dir as...
Summary Hi. I'm able to use import { createHmac } from 'node:crypto' in app/api/route.ts file but importing it in /middleware.ts file I get this error: node:crypto Module build failed: ...
GitHub
examples/edge-middleware/crypto/middleware.ts at main ยท vercel/exam...
Enjoy our curated collection of examples and solutions. Use these patterns to build your own robust and scalable applications. - vercel/examples
Using Crypto in Edge Middleware and Edge Functions โ€“ Vercel
Learn to utilize the crypto Web APIs at the edge.
2 Replies
rphlmr โšก
rphlmr โšกโ€ข16mo ago
I think it is more related to the driver than Drizzle itself I've tried with postgres.js (net module error) and pg (crypto module error) I would try another strategy, middleware seems limited ๐Ÿฅถ
culture_59893
culture_59893OPโ€ข16mo ago
ah interesting, thanks, I'll try an API call or something instead...
Want results from more Discord servers?
Add your server