tasko/middleware.ts

29 lines
619 B
TypeScript
Raw Normal View History

2024-03-21 21:15:27 +00:00
import { clerkMiddleware } from '@clerk/nextjs/server';
2024-12-27 23:24:19 +00:00
import arcjet, { shield, detectBot } from './lib/arcjet';
import { createMiddleware } from '@arcjet/next';
2024-03-21 21:15:27 +00:00
2024-12-27 23:24:19 +00:00
const aj = arcjet
.withRule(
shield({
mode: 'LIVE',
})
)
.withRule(
detectBot({
mode: 'LIVE',
2024-12-27 23:41:00 +00:00
allow: [
'CATEGORY:SEARCH_ENGINE',
'CATEGORY:VERCEL',
'CATEGORY:MONITOR',
'CATEGORY:PREVIEW',
'CATEGORY:OPTIMIZER',
],
2024-12-27 23:24:19 +00:00
})
);
2024-03-21 21:15:27 +00:00
export const config = {
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};
export default createMiddleware(aj, clerkMiddleware());