-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
35 lines (29 loc) · 788 Bytes
/
proxy.ts
File metadata and controls
35 lines (29 loc) · 788 Bytes
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
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
const isPublicRoute = createRouteMatcher([
"/",
"/sign-in(.*)",
"/sign-up(.*)",
"/api/webhook",
"/question/:id",
"/tags",
"/tags/:id",
"/profile/:id",
"/community",
"/jobs",
]);
export default clerkMiddleware((auth, request) => {
const { pathname } = request.nextUrl;
// Ignore Next.js internals & static assets
if (pathname.startsWith("/_next") || pathname.startsWith("/favicon.ico")) {
return NextResponse.next();
}
// Protect non-public routes
if (!isPublicRoute(request)) {
auth.protect();
}
return NextResponse.next();
});
export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};