-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
39 lines (36 loc) · 1.07 KB
/
middleware.ts
File metadata and controls
39 lines (36 loc) · 1.07 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
/**
* Root Next.js middleware.
*
* Intercepts all matched requests to refresh the Supabase session
* and enforce authentication on protected routes.
*
* @module middleware
*/
import { updateSession } from "@/lib/supabase/middleware";
import type { NextRequest } from "next/server";
/**
* Middleware function invoked on every matching request.
* Delegates to the Supabase session updater for auth management.
*
* @param request - The incoming Next.js request
* @returns NextResponse with session cookies
*/
export async function middleware(request: NextRequest) {
return await updateSession(request);
}
/**
* Matcher configuration.
* Excludes static assets, images, and favicon from middleware processing.
*/
export const config = {
matcher: [
/*
* Match all request paths except:
* - _next/static (static files)
* - _next/image (image optimization)
* - favicon.ico (favicon)
* - public assets (icons, manifest, images)
*/
"/((?!_next/static|_next/image|favicon.ico|icons/|manifest.json|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
],
};