Skip to content

Commit 4ec4de1

Browse files
fix(web): prevent crash when User-Agent header is missing (#1309)
* 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> * docs: add CHANGELOG entry for #1309 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4ec87e1 commit 4ec4de1

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818
- Validated that `SOURCEBOT_ENCRYPTION_KEY` is exactly 32 characters at startup, failing fast with an actionable message instead of a runtime encryption error. [#1305](https://github.com/sourcebot-dev/sourcebot/pull/1305)
19+
- Fixed the web UI crashing when anonymous access is enabled and a request omits the `User-Agent` header (e.g. proxy or health-check probes). [#1309](https://github.com/sourcebot-dev/sourcebot/pull/1309)
1920

2021
## [5.0.2] - 2026-06-11
2122

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)