Repository navigation
fix(server-sdk): keep the base path of the server URL in API requests - #742
Open
ANDROIDHASSAN wants to merge 1 commit into
Open
ANDROIDHASSAN wants to merge 1 commit into
ANDROIDHASSAN wants to merge 1 commit into
Conversation
new URL(path, host) with the absolute Twirp path replaced any path on the host, so a server behind a reverse proxy at https://example.com/livekit was called at https://example.com/twirp/... Append the Twirp path to the host's own path instead, as the Go and Python server SDKs do.
🦋 Changeset detectedLatest commit: ef095c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TwirpRpc.requestbuilds the request URL withnew URL(path, current). The Twirp path starts with/(/twirp/livekit.RoomService/ListRooms), so it replaces any path on the host instead of being appended to it. A server reached under a path, e.g. behind a reverse proxy athttps://example.com/livekit, is called athttps://example.com/twirp/...:The Go server SDK hands the URL to the generated Twirp client, which appends
/twirp/...to it, and the Python server SDK keeps the base path too (livekit/python-sdks#861). This brings the Node SDK in line.The path is now appended to the host's own path (
twirpUrl), dropping any query string or fragment on the host. Failover is unchanged: fallback regions are bare origins, so a retry goes tohttps://<region>/twirp/....Tests in
TwirpRPC.test.ts(request url):https://example.com/livekit, with a trailing slash, and for awss://URL; a custom prefix works with or without a leading slash; a query string or fragment on the host is dropped. These fail onmain(the base path is missing) and pass now. A host without a path gives the same URL as before.vitest run srcpasses in the node, edge-runtime and happy-dom environments (51 tests);eslint,prettier --checkandtsc --noEmitpass. A changeset is included (patch). The changeset notes the one behaviour change: a URL that carries a path the server does not serve the API under should drop it.