Middleware :path not working
Answered
Catla posted this in #help-forum
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?
5 Replies
CatlaOP
Bump
@joulev i think its supposed to be `:path*` with a star
CatlaOP
Super easy fix. Thanks for your help.
you're welcome
Gharial
how did you make your middleware work in prod?
mine works in dev environment, but it does not fire up after compiling
mine works in dev environment, but it does not fire up after compiling