DevFlow

Dev Flow

search

NextJS middleware does not seem to be triggered

clock icon

asked 7 months agoAsked

message

0Answers

eye

3Views

I have the middleware.js file within /myproject/pages/middleware.js:

export function middleware(request) {
  console.log(1)
  return NextResponse.redirect(new URL('/', request.url))
}

// See "Matching Paths" below to learn more
export const config = {
  matcher: ['/test'],
}

Now what I expect is when i go to the page /test then it should redirect me to /. However nothing happens and I see my standard 404 page.

0 Answers

Write your answer here