Problem with middleware matcher config
Answered
Tan posted this in #help-forum
TanOP
Hey guys, i'm facing a problem on middleware.ts file
Here is my config in middleware.ts based on src directory
i just want to include all routes excepts /login route but i can't
Even if I try this:
OR THIS
`source` does not start with / for route {"source":"/((?!login).*)"}
Here is my config in middleware.ts based on src directory
export const config = {
matcher: [
"/((?!login).*)", // Exclude only /login route
],
};
i just want to include all routes excepts /login route but i can't
Even if I try this:
export const config = {
matcher: ["/dashboard"],
};
✓ Starting...
`source` does not start with / for route {"source":"/dashboard"}
Error: Invalid middleware found
OR THIS
export const config = {
matcher: "/dashboard",
};
Answered by Tan
I have upgraded next js version in 15 and I don't have the problem anymore
Thank you
Thank you
7 Replies
try this @Tan
export const config = {
matcher: [
"/((?!^/login$).*)", // Exclude the exact /login route
],
};
did you try ⬆️ ? @Tan
TanOP
I will try tonight and let you know
Thanks for the answer
If that’s the solution I will mark the answer as valid 🙂
Thanks for the answer
If that’s the solution I will mark the answer as valid 🙂
TanOP
TanOP
Up please
Can you provide a min repro repo?
TanOP
I have upgraded next js version in 15 and I don't have the problem anymore
Thank you
Thank you
Answer