Skip to content

fix(api): preserve base URL paths in Twirp requests - #842

Draft
Kayvan-Zahiri wants to merge 1 commit into
livekit:mainfrom
Kayvan-Zahiri:codex/fix-api-base-path
Draft

Kayvan-Zahiri wants to merge 1 commit into
livekit:mainfrom
Kayvan-Zahiri:codex/fix-api-base-path

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

When LiveKitAPI is given a URL such as https://example.com/proxy/livekit, API requests currently go to /twirp/... and drop /proxy/livekit. A proxy that routes the API under that path therefore returns 404. The request loop builds URLs from the origin, which intentionally excludes the path.

Keep the normalized base path separately and include it when constructing each Twirp request, including retries. This also removes the extra slash inserted while reconstructing self.host.

Added local HTTP-server regressions covering HTTP and WebSocket-style URLs, empty and nested base paths, trailing slashes, and failover with default/custom Twirp prefixes. The failover tests also verify the request body and idempotency key stay the same across attempts.

Validation:

  • The prefixed-route cases reproduce a 404 before the fix; unprefixed routes pass.
  • pytest tests/api against the official LiveKit mock server bound to localhost: 46 passed (Python 3.12).
  • Ruff lint/format checks for the new tests and git diff --check: pass.

@CLAassistant

CLAassistant commented Oct 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants