Better optimize middleware matcher

This commit is contained in:
Jared Schoeny
2026-07-22 14:21:53 -06:00
parent 556d28235e
commit b13dbc3033

View File

@@ -6,6 +6,8 @@ export async function middleware(request: NextRequest) {
return await updateSession(request)
}
// All values must be hardcoded in the middleware config,
// which is why the project ID is hardcoded for the cookie key.
export const config = {
matcher: [
/*
@@ -15,6 +17,19 @@ export const config = {
* - favicon.ico (favicon file)
* Feel free to modify this pattern to include more paths.
*/
'/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
{
// Production
source: '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
has: [
{ type: 'cookie', key: 'sb-scfxbqapigdjfebqwmoj-auth-token' },
]
},
{
// Local development
source: '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
has: [
{ type: 'cookie', key: 'sb-127-auth-token' },
]
},
],
}