Next.js middleware handler is not a function
Unanswered
aa55h posted this in #help-forum
11 Replies
i use
next@15.4.0-canary.67is the middleware at the root folder? if yes then try removing nodejs runtime
also i think first if statement wont run, matcher only has home, sign-in, sign-up and error, not api/auth route on it
also i think first if statement wont run, matcher only has home, sign-in, sign-up and error, not api/auth route on it
yes, I was reading this post
https://community.vercel.com/t/middlewarehandler-is-not-a-function/8757
and some solutions were someone who had it on app folder instead of src
or removing nodejs runtime for now as workaround until they fix it
seems like a new bug
https://community.vercel.com/t/middlewarehandler-is-not-a-function/8757
and some solutions were someone who had it on app folder instead of src
or removing nodejs runtime for now as workaround until they fix it
seems like a new bug
@chisto yes, I was reading this post
https://community.vercel.com/t/middlewarehandler-is-not-a-function/8757
and some solutions were someone who had it on app folder instead of src
or removing nodejs runtime for now as workaround until they fix it
seems like a new bug
aa55hOP
i use better auth in middleware - so now it causes
The edge runtime does not support Node.js 'crypto' module.ah sorry, didn't know you were using better auth
have you tried using getSessionCookie from "better-auth/cookies" ? since you don't need the full session object
have you tried using getSessionCookie from "better-auth/cookies" ? since you don't need the full session object
I haven't use better auth but that's on their docs
I think the nodejs runtime is still experimental and some libraries aren't ready yet, better do it the old way
In Next.js middleware, it's recommended to only check for the existence of a session cookie to handle redirection. To avoid blocking requests by making API or database calls.
You can use the getSessionCookie helper from Better Auth for this purpose
I think the nodejs runtime is still experimental and some libraries aren't ready yet, better do it the old way
did you have nodeMiddleware:true on your next config when u had runtime nodejs?
from middleware