Nextjs v15.5.2 - Middleware runtime flag not working
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
Hello fellow NextJS devs!
Just testing out this new
Here is my current middleware file:
Things i've tried:
- Nuking both the
- Adding the experimental nodeMiddleware flag to my next.config.ts (TS linter highlights this field as an invalid key in the ExperimentalConfig type - Casted the object to get around this but still no luck)
Wondering if I missed something dumb here, or maybe if anyone else is experiencing this same behaviour/can reproduce it?
Just testing out this new
runtime: 'nodejs'
flag in my middleware on next: '15.5.2'
, but running into a bit of trouble here. No matter what I do the NextJS output always shows the same error message from older versions: ⨯ Error: The edge runtime does not support Node.js 'crypto' module.
. Here is my current middleware file:
export const config = {
runtime: 'nodejs',
};
export { auth as middleware } from '@/config/auth';
Things i've tried:
- Nuking both the
.next
and node_modules
folders, and running npm i
and re-running the dev server npm run dev
- Adding the experimental nodeMiddleware flag to my next.config.ts (TS linter highlights this field as an invalid key in the ExperimentalConfig type - Casted the object to get around this but still no luck)
Wondering if I missed something dumb here, or maybe if anyone else is experiencing this same behaviour/can reproduce it?
5 Replies
Chub mackerel
double-check that your Nextjs is 15.5+ with
npm ls next
Polar bearOP
Looks to be the case, here's the output:
├─┬ next-auth@5.0.0-beta.29
│ └── next@15.5.2 deduped
└── next@15.5.2
├─┬ next-auth@5.0.0-beta.29
│ └── next@15.5.2 deduped
└── next@15.5.2
Chub mackerel
it may acutlly be a Nextjs bug, open Github issue about it
Polar bearOP
Sounds good, will follow up on this in the morning. Thanks for lending a hand!
Oh, I see. I think inside the middleware, you use bcrypt, right? I see bcrypt is not running on the edge runtime. this https://www.youtube.com/watch?v=DJvM2lSPn6w they use joes package or you can use any edge support package