-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
52 lines (42 loc) · 1.45 KB
/
middleware.ts
File metadata and controls
52 lines (42 loc) · 1.45 KB
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
48
49
50
51
52
import { NextResponse } from "next/server";
import { NextRequest } from "next/server";
export default function middleware(req: NextRequest) {
console.log("Middleware running for:", req.nextUrl.pathname);
return NextResponse.next();
}
export const config = {
matcher: ["/((?!.+\\.[\\w]+$|_next).*)"],
};
// This is an example of how to use Clerk middleware for authentication
// WORKED FINE FOR SOME TIME COULDN'T GET IT TO WORK AGAIN
// import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
// const isPublicRoute = createRouteMatcher([
// "/",
// "/about",
// "/eras/(.*)",
// "/sign-in(.*)",
// "/sign-up(.*)",
// "/api/webhook", // Add this to exclude webhook from auth checks
// ]);
// const isProtectedRoute = createRouteMatcher(["/upload"]);
// export default clerkMiddleware(async (auth, req) => {
// const authObject = await auth();
// if (isPublicRoute(req)) {
// return;
// }
// if (!authObject.userId) {
// return authObject.redirectToSignIn();
// }
// if (isProtectedRoute(req)) {
// type PublicMetadata = { role?: string };
// const publicMetadata = (authObject.sessionClaims?.publicMetadata ||
// {}) as PublicMetadata;
// const userRole = publicMetadata.role;
// if (userRole !== "admin") {
// return Response.redirect(new URL("/", req.url));
// }
// }
// });
// export const config = {
// matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"],
// };