Next.js Discord

Discord Forum

Middleware :path not working

Answered
Catla posted this in #help-forum
Open in Discord
CatlaOP
import NextAuth from "next-auth";
import authConfig from "./auth.config";

const { auth } = NextAuth(authConfig);

export default auth((req) => {
    const { nextUrl } = req;
    const callbackUrl = nextUrl.pathname;
    const isLoggedIn = req.auth;

    if (!isLoggedIn) {
        return Response.redirect(new URL(`/api/signIn?callbackUrl=${callbackUrl}`, nextUrl));
    };

    return;
});

export const config = {
    matcher: ['/manage/guilds', '/manage/guilds/:path', '/manage/accounts'],
};


Hi. For some reason my matcher /manage/guilds/:path does not redirect users to the mentioned URL if not signed in. The other matchers do.
Why?
Answered by joulev
i think its supposed to be :path* with a star
View full answer

5 Replies