Files
stats/apps/dashboard/src/middleware.ts
Carl-Gerhard Lindesvärd 32e91959f6 chore(root): migrate to biome
2024-09-18 23:46:11 +02:00

34 lines
799 B
TypeScript

import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
// 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 isPublicRoute = createRouteMatcher([
'/share/overview/:id',
'/api/clerk/(.*)?',
'/login(.*)?',
'/register(.*)?',
'/sso-callback(.*)?',
]);
export default clerkMiddleware(
(auth, req) => {
if (!isPublicRoute(req)) {
auth().protect();
}
},
{
debug: !!process.env.CLERK_DEBUG,
},
);
export const config = {
matcher: [
'/((?!.+\\.[\\w]+$|_next).*)',
'/',
'/(api)(.*)',
'/(api|trpc)(.*)',
'/api/trpc(.*)',
],
};