Next.js Discord

Discord Forum

Next Auth middleware allow "/" but redirect everything else.

Unanswered
Plott Hound posted this in #help-forum
Open in Discord
Plott HoundOP
I'm trying to make it so non authenticated users can see the landing page at "/" but any other page takes them to login.

If I use: export { default } from "next-auth/middleware"; it will redirect all pages to login.

I tried using this but it still redirects "/" to login:
export { default } from "next-auth/middleware";

export const config = {
  matcher: (req) => {
    if (req.url.startsWith("/_next")) return false;
    if (req.url === "/") return false;
    return true;
  },
};


Does anyone know how i can do this? Thanks

1 Reply

Plott HoundOP
Bump