Is this the worse software ever? #2076
Replies: 1 comment 6 replies
-
Hey Bilal, Sorry for the frustration. I just put an example repo up for your use-case here. Here's a snippet you can use for your middleware: import { authMiddleware, redirectToSignIn } from "@clerk/nextjs";
export default authMiddleware({
afterAuth(auth, req, evt) {
// handle users who aren't authenticated and access /dashboard
if (!auth.userId && req.nextUrl.pathname.startsWith("/dashboard")) {
return redirectToSignIn({ returnBackUrl: req.url });
}
},
});
export const config = {
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"],
}; Let me know if this works, and I can help with anything else! |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Seriously -
What were you smoking when you decided to make every route private? Next.js Middleware is completely broken, huge performance hits. Vercel builds failing because of a 250MB limit being exceeded since 13.4.9 (past 3 months). Millions raised and no one gives a F***. What the hell are you guys doing?!
I want to leave you but much like someone stuck with an abusive spouse I am stuck with you for this project because the effort to switch is too much right now.
Please please please. All I want is a functioning app where /dashboard(.) is protected and you leave everything else the f** alone. Can you do this for Next.14?
Beta Was this translation helpful? Give feedback.
All reactions