fix(pos): handle expired API sessions and add receipt preview close button
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user