fix(pos): handle expired API sessions and add receipt preview close button

This commit is contained in:
Deploy
2026-08-26 07:05:02 +02:00
parent b6af852b54
commit 290ced173b
14 changed files with 52 additions and 17 deletions

View File

@@ -20,6 +20,15 @@ export function proxy(request: NextRequest) {
cookie.includes('session_token=');
if (!hasSession) {
// API callers expect JSON. Redirecting them to /login makes fetch() follow
// the redirect and receive the HTML login page, which surfaces as the
// cryptic "Unexpected token '<'" parse error in the terminal UI.
if (pathname.startsWith('/api/')) {
return NextResponse.json(
{ error: { statusCode: 401, code: 'UNAUTHORIZED', message: 'Authentication required' } },
{ status: 401 },
);
}
return NextResponse.redirect(new URL('/login', request.url));
}