// middleware.ts
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
const isProtectedRoute = createRouteMatcher(["/projects(.*)", "/waitlist(.*)"]);
export default clerkMiddleware((auth, req) => {
const signInUrl = new URL("/sign-in", req.url).toString();
if (isProtectedRoute(req)) {
auth().protect({ unauthenticatedUrl: signInUrl });
}
return NextResponse.next();
});
export const config = {
matcher: [
// Exclude files with a "." followed by an extension, which are typically static files.
// Exclude files in the _next directory, which are Next.js internals.
"/((?!.+\\.[\\w]+$|_next|monitoring).*)",
// Re-include any files in the api or trpc folders that might have an extension
"/(api|trpc)(.*)",
],
};
// middleware.ts
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
const isProtectedRoute = createRouteMatcher(["/projects(.*)", "/waitlist(.*)"]);
export default clerkMiddleware((auth, req) => {
const signInUrl = new URL("/sign-in", req.url).toString();
if (isProtectedRoute(req)) {
auth().protect({ unauthenticatedUrl: signInUrl });
}
return NextResponse.next();
});
export const config = {
matcher: [
// Exclude files with a "." followed by an extension, which are typically static files.
// Exclude files in the _next directory, which are Next.js internals.
"/((?!.+\\.[\\w]+$|_next|monitoring).*)",
// Re-include any files in the api or trpc folders that might have an extension
"/(api|trpc)(.*)",
],
};