Skip to content

Commit cc77b9e

Browse files
fix(web): prevent crash when User-Agent header is missing
When anonymous access is enabled, session-less requests fall through to the (app) layout's mobile-detection check instead of redirecting to /login. Requests without a User-Agent header (e.g. proxy/health-check probes) caused getSelectorsByUserAgent('') to return undefined, throwing a TypeError on the isMobile destructure and crashing the web UI. Only call getSelectorsByUserAgent when a non-empty User-Agent is present. Fixes #1308 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4ec87e1 commit cc77b9e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/web/src/app/(app)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default async function Layout(props: LayoutProps) {
148148
const headersList = await headers();
149149
const cookieStore = await cookies()
150150
const userAgent = headersList.get('user-agent');
151-
const { isMobile } = getSelectorsByUserAgent(userAgent ?? '');
151+
const { isMobile } = userAgent ? getSelectorsByUserAgent(userAgent) : { isMobile: false };
152152

153153
if (isMobile && !cookieStore.has(MOBILE_UNSUPPORTED_SPLASH_SCREEN_DISMISSED_COOKIE_NAME)) {
154154
return (

0 commit comments

Comments
 (0)