From 9215500987a75681bc14f29d04cb2f838f266c0a Mon Sep 17 00:00:00 2001 From: Sahil Lavingia Date: Fri, 27 Sep 2024 16:47:12 -0400 Subject: [PATCH] protect route --- middleware.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/middleware.ts b/middleware.ts index 4921dd2c..c62bf59e 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,11 +1,14 @@ import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server"; -const isProtectedRoute = createRouteMatcher(["/dashboard(.*)"]); +const isProtectedRoute = createRouteMatcher([ + "/dashboard(.*)", + "/api/generate-tests(.*)", +]); export default clerkMiddleware((auth, req) => { if (isProtectedRoute(req)) auth().protect(); }); export const config = { - matcher: ["/((?!.*\\..*|_next).*)", "/"], + matcher: ["/((?!.*\\..*|_next).*)", "/", "/api/generate-tests(.*)"], };