Next.js Discord

Discord Forum

Redirect to custom login page creates a URL-loop with JWT

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hi!

I am using a middleware.ts file in my root-directory to redirect all users that isn't authenticated. However, if I put a custom login page inside my catch-all route handler. When I sign out, my url gets populated with some loop and the server crashes, any ideas to why?

file: api/auth/[...nextauth]/route.ts

content at the bottom:

pages: {
  signIn: "/login",
},
debug: process.env.NODE_ENV === "development",
session: {
  strategy: "jwt",
},
secret: process.env.NEXTAUTH_SECRET,

0 Replies