Next.js Discord

Discord Forum

Middleware hides 404

Unanswered
Giant Chinchilla posted this in #help-forum
Open in Discord
Giant ChinchillaOP
I'm using a middleware to check if a user is authed. If they are not, they are redirected to the sign in page.
The problem is that now unauthed users cannot access 404 pages because they are redirected, the simple pseudo-logic is like:
  //... middleware.ts...
  if (session) {
    return NextResponse.next()
  }

  return NextResponse.redirect(new URL('/auth/sign-in', request.url))

0 Replies