getIronSession doesn't work with edge-runtime middleware
Maders opened this issue ยท 4 comments
When I use getIronSession
(according to your docs) with the stable version of next.js middleware (12.2), which runs on edge runtime. throws this error:
error - (middleware)/node_modules/@peculiar/webcrypto/build/webcrypto.es.js (9:0) @ new SubtleCrypto
error - The edge runtime does not support Node.js 'crypto' module.
Is there something I missed?
Your help is greatly appreciated; thanks.
Packages:
"next": "^12.2.5",
"iron-session": "^6.2.0",
Most likely you've imported non-edge version inside your src/core/server/iron-session file.
Thank for you help. Yes, I re-exported the custom versions of withSession Route/Ssr
in the index file of that directory.
Might it be better to mention this in the readme?
Hello, i had a same problems with iron-session@6.2.0. How do you resolve this issue ? @Maders
Thanks
Hello, i had a same problems with iron-session@6.2.0. How do you resolve this issue ? @Maders
You must not import withSessionSsr or withSessionRoute or any other thing from 'iron-session' in the middleware file.
In my screenshot, I re-export a custom version of withSession functions in the index file of src/core/server/iron-session
so the bundler resolves these functions when importing ironOptions