@@ -2,12 +2,16 @@ import { ComponentLibType } from "../../../../types.js";
22import { formatFilePath , getFilePaths } from "../../../filePaths/index.js" ;
33
44const generateMiddlewareTs = ( ) => {
5- return `import { authMiddleware } from " @clerk/nextjs" ;
5+ return `import { clerkMiddleware, createRouteMatcher } from ' @clerk/nextjs/server' ;
66
77// This example protects all routes including api/trpc routes
88// Please edit this to allow other routes to be public as needed.
9- // See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your middleware
10- export default authMiddleware({ ignoredRoutes: ["/"] });
9+ // See https://clerk.com/docs/references/nextjs/clerk-middleware for more information about configuring your middleware
10+ const isProtectedRoute = createRouteMatcher([]);
11+
12+ export default clerkMiddleware((auth, req) => {
13+ if (isProtectedRoute(req)) auth().protect();
14+ });
1115
1216export const config = {
1317 matcher: ['/((?!.+\\\\\.[\\\\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
@@ -19,7 +23,7 @@ const generateSignInPageTs = () => {
1923export default function Page() {
2024 return (
2125 <main className="grid place-items-center pt-4">
22- <SignIn redirectUrl ={"/dashboard"} />
26+ <SignIn fallbackRedirectUrl ={"/dashboard"} />
2327 </main>
2428 );
2529}` ;
@@ -30,7 +34,7 @@ const generateSignUpPageTs = () => {
3034export default function Page() {
3135 return (
3236 <main className="grid place-items-center pt-4">
33- <SignUp redirectUrl ={"/dashboard"} />
37+ <SignUp fallbackRedirectUrl ={"/dashboard"} />
3438 </main>
3539 );
3640}` ;
0 commit comments