-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.ts
35 lines (29 loc) · 1.03 KB
/
middleware.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* this code will make our authentication routes private. Source: dashboard.clerk.com */
// import { clerkMiddleware } from "@clerk/nextjs/server";
// export default clerkMiddleware();
// 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)(.*)",
// ],
// };
/* this code will make our authentication routes public. Source: Nextjs.org */
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
const isPublicRoute = createRouteMatcher([
"/api/:path*",
"/sign-in(.*)",
"/sign-up(.*)",
]);
export default clerkMiddleware((auth, request) => {
if (!isPublicRoute(request)) {
auth().protect();
}
});
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
// Always run for API routes
"/(api|trpc)(.*)",
],
};