Error: The edge runtime does not support Node.js 'crypto' module
This error only come up after I added middleware
Searched issue on GitHub , no report about it on better-auth (or I am blind)
tried to search more info appears that next-auth also have same issue as better-auth
I need help here: How to bypass it or we have to not use middleware until it fixes?
My middleware.ts:
It seems like a
Next-auth also have the sameissue:
## After I try adding into config from next js docs:
Haven't tried the canary version yet
Searched issue on GitHub , no report about it on better-auth (or I am blind)
tried to search more info appears that next-auth also have same issue as better-auth
I need help here: How to bypass it or we have to not use middleware until it fixes?
My middleware.ts:
What I did:
- I create new next js app to try out better auth
- I follow the installation guide here
- I install mongo db adapter guide here
- I copy and modify
middleware.tsto work with my directory - bug ->This error occurs (the Image)
The error:
My attempt:
It seems like a
next issue but I make a help request hereNext-auth also have the sameissue:
## After I try adding into config from next js docs:
Haven't tried the canary version yet

GitHub
Environment System: OS: Windows 10 10.0.19045 CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz Memory: 19.24 GB / 31.96 GB Binaries: Node: 21.1.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22....