Skip to content

Commit

Permalink
fix middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
khabzox committed Aug 29, 2024
1 parent cb9a4f9 commit 5ffa1e1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions apps/nextjs-app/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,21 @@ const isPublicRoute = createRouteMatcher([
]);

const isPublicApi = createRouteMatcher([
"/api(.*)",
"/api/tutorial(.*)",
"/api/search(.*)",

]);

export default clerkMiddleware((auth, req) => {
if (isPublicRoute(req) || isPublicApi(req)) {
console.log("Public Route or API accessed:", req.url);
return; // Allow access without authentication
return;
}
console.log("Private Route accessed:", req.url);
auth().protect(); // Require authentication
auth().protect();
});


export const config = {
matcher: [
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
"/",
"/(api|trpc)(.*)",
],
};

0 comments on commit 5ffa1e1

Please sign in to comment.