-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.ts
47 lines (42 loc) · 1.24 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
36
37
38
39
40
41
42
43
44
45
46
47
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
// In "ClerkMiddelware" all routes are public while 'authMiddleware' is vice-versa
// 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
const isPublicRoutes = createRouteMatcher([
"/",
"/home",
"/api/webhooks(.*)",
"/question/:id",
"/tags/:id",
"/tags",
"/profile/:id",
"/community",
"/jobs",
"/sign-in(.*)",
"/sign-up(.*)",
"/api/chatgpt",
]);
// exclude public routes and Protect all other routes.
export default clerkMiddleware((auth, request) => {
if (!isPublicRoutes(request)) {
auth().protect();
}
});
// NOTE: 'authMiddleware' is depriciated, So we're using clerkMiddleware
// export default authMiddleware({
// publicRoutes: [
// "/",
// "/api/webhooks(.*)",
// "/question/:id",
// "/tags/:id",
// "/tags",
// "/profile/:id",
// "/community",
// "/jobs",
// ],
// ignoredRoutes: ["/api/webhooks(.*)", "/api/chatgpt"],
// });
export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};