Skip to content

Commit

Permalink
Merge pull request #192 from Kairedblue/update/clerk-core
Browse files Browse the repository at this point in the history
Update Clerk's new middleware and auth page props
  • Loading branch information
nicoalbanese authored Jun 23, 2024
2 parents 4db684c + 31ed43c commit bb5b0f8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/add/auth/clerk/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { ComponentLibType } from "../../../../types.js";
import { formatFilePath, getFilePaths } from "../../../filePaths/index.js";

const generateMiddlewareTs = () => {
return `import { authMiddleware } from "@clerk/nextjs";
return `import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
// This example protects all routes including api/trpc routes
// Please edit this to allow other routes to be public as needed.
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your middleware
export default authMiddleware({ ignoredRoutes: ["/"] });
// See https://clerk.com/docs/references/nextjs/clerk-middleware for more information about configuring your middleware
const isProtectedRoute = createRouteMatcher([]);
export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
});
export const config = {
matcher: ['/((?!.+\\\\\.[\\\\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
Expand All @@ -19,7 +23,7 @@ const generateSignInPageTs = () => {
export default function Page() {
return (
<main className="grid place-items-center pt-4">
<SignIn redirectUrl={"/dashboard"} />
<SignIn fallbackRedirectUrl={"/dashboard"} />
</main>
);
}`;
Expand All @@ -30,7 +34,7 @@ const generateSignUpPageTs = () => {
export default function Page() {
return (
<main className="grid place-items-center pt-4">
<SignUp redirectUrl={"/dashboard"} />
<SignUp fallbackRedirectUrl={"/dashboard"} />
</main>
);
}`;
Expand Down

0 comments on commit bb5b0f8

Please sign in to comment.