diff --git a/src/middleware.ts b/src/middleware.ts index e3c0192..102e5c8 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -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' }, + ] + }, ], }