#Crypto module not working on edge

6 messages · Page 1 of 1 (latest)

fallen shale
#

I'm using the 'crypto' Node.js module in my middleware logic, but even thought documentation says it is supported at the edge runtime, the logs when I deploy it says the following:

A Node.js module is loaded ('crypto' at line 2) which is not supported in the Edge Runtime. Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime

Then what could I use instead or how to fix it?

hollow stump
#

Node js modules etc are not supported in middlewares due to edge runtime. A work around that might work for you is to create an api endpoint and do your stuff there. Then in the middleware call the api end point using the desired method and play with the response from it . Hope you get my point . Also a side note to this approach I'm not sure if its recommended so feel free to correct me 🙂

fallen shale
hollow stump
#

Am what are you trying to do with it ... If you click on the crypto link it says global read only props

fallen shale
hollow stump
#

No idea tbf I haven't used crypto in a middleware before 😦