-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmiddleware.ts
37 lines (33 loc) · 1.39 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
// Import Clerk authentication middleware
import { clerkMiddleware } from "@clerk/nextjs/server"
// Apply Clerk middleware to protect routes
export default clerkMiddleware()
/**
* Middleware configuration for route protection
*
* The matcher array defines which routes should be processed by the middleware:
* 1. Static file exclusions - Skip Next.js internal routes and static files
* 2. API routes - Always apply middleware to API endpoints
* 3. Protected application routes - Require authentication
*/
export const config = {
matcher: [
// Skip Next.js internals and static files
// Matches all routes EXCEPT:
// - Next.js internal routes (_next/*)
// - Static files with common extensions (html, css, js, images, fonts, etc.)
// Unless they are found in search parameters
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
// Always process API routes
// Includes both standard API routes and tRPC endpoints
"/(api|trpc)(.*)",
// Protected application routes
// These routes require authentication:
"/notification-channels(.*)", // Notification channel management
"/prompts(.*)", // AI prompt management
"/schedules(.*)", // Schedule management
"/dashboard(.*)", // User dashboard
"/reporters(.*)", // Reporter management
"/archives(.*)", // Archived content
],
}