Nextjs middleware being ignored
Hey, this is driving me crazy, using next, why I'm not being redirected to "/pending" by the middleware when pushed to "/dashboard" from a different (login) route using useRouter push
login.tsx
route
root middlware middleware.ts
3 Replies
Where does
redirect(url, req)
comes from ? I believe you should return NextResponse.redirect(url)
insteadit is custom function
i think its a prefetch thing, because if I do a full refresh on the dashboard route it works fine
Yeah, your example works fine on my end. Maybe try adding some logs to make sure the url is what you expect, and that
redirect()
is actually called. I don't see anything wrong with the code...