fix: correct Logto session cookie prefix in middleware

Cookie is named `logto_<appId>` not `logto:<appId>`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-04-07 08:56:21 -04:00
parent 8462aa9ef4
commit 6328a8d0d3

View file

@ -10,9 +10,9 @@ export function middleware(request: NextRequest) {
}
// Protected routes: check for Logto session cookie
// The Logto SDK stores session data in a cookie named `logto:<appId>`
// The Logto SDK stores session data in a cookie named `logto_<appId>`
const hasSession = request.cookies.getAll().some(
(cookie) => cookie.name.startsWith('logto:')
(cookie) => cookie.name.startsWith('logto_')
);
if (!hasSession && !pathname.startsWith('/auth')) {