fix(qbittorrent): add URL Base support for reverse-proxied instances#772
Open
schmitzkr wants to merge 1 commit into
Open
fix(qbittorrent): add URL Base support for reverse-proxied instances#772schmitzkr wants to merge 1 commit into
schmitzkr wants to merge 1 commit into
Conversation
qBittorrent's download client only had Host/Port, so it always connected at the root path and couldn't reach instances served behind a path-prefixed reverse proxy (Transmission already had this field). Unlike Transmission's urlBase, which replaces the whole RPC path to match Transmission's own configurable --rpc-url-base daemon setting, qBittorrent has no equivalent server-side base path setting (upstream qbittorrent/qBittorrent#21471 and #23467 are both unmerged), so this prepends urlBase as a plain prefix before the fixed /api/v2/... routes instead of replacing them. Closes Listenarrs#690. Co-Authored-By: Claude Sonnet 5 <[email protected]>
schmitzkr
marked this pull request as ready for review
July 20, 2026 20:23
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.
Summary
Adds a "URL Base" field to the qBittorrent download client (closes #690), so Listenarr can reach qBittorrent instances served behind a path-prefixed reverse proxy (e.g.
example.com/qbittorrent) — matching the field Transmission's client already has.I deliberately didn't just copy Transmission's mechanism. Transmission's
urlBasereplaces its whole RPC path, because that mirrors Transmission's own daemon setting (--rpc-url-base) — Listenarr just matches whatever arbitrary path the user configured server-side. qBittorrent has no equivalent: I checked upstream, and a native WebUI base-path setting has been proposed twice (qbittorrent/qBittorrent#21471, closed unmerged; #23467, still open/unmerged) — neither has shipped. So every real qBittorrent-behind-a-proxy deployment today works by the reverse proxy stripping a path prefix before it reaches qBittorrent, which always serves at its own root regardless. That means the correct semantics here are a prefix prepended before the fixed/api/v2/...routes, not a full-path override.Changes
Added
QBittorrentHelpers.BuildBaseUrl()— composes authority + normalizedurlBaseprefix from client settings; no-op when unset, so existing configs are unaffected/qbittorrent/api/v2/app/versionwhen configuredChanged
DownloadClientUriBuilder.BuildAuthority(client)now go through the new helper instead (mechanical, one line each — no other behavior change)Testing
dotnet build/dotnet format --verify-no-changescleanvue-tscclean, full suite 393/393 passNotes
AI assistance disclosure: this PR was developed with Claude Code's assistance - the implementation (the helper, the 8-file sweep, the frontend field, and the tests) was written by Claude Code. My role was directing the approach and validating the result: I pushed back on an initial draft that assumed we should just copy Transmission's urlBase mechanism, which prompted the investigation that found qBittorrent needs different (prefix, not replace) semantics - that upstream research and the resulting design decision are reflected above. I also manually tested this against my own qBittorrent instance behind a real reverse proxy and confirmed it resolves the actual problem reported in #690, which is real, live validation beyond the automated test suite. I have not done a line-by-line manual read of the full diff myself - flagging that plainly since this is my first PR on a project I don't maintain, and I'd rather be upfront about the split between direction/testing and code-writing than imply a level of manual review that didn't happen.
One unrelated thing noticed while auditing every place qBittorrent builds a URL: there are 5 separate, independently-written login implementations across these files (pre-existing, not introduced by this change), and only one of them sets a
Referrerheader that qBittorrent's CSRF check can care about. It shouldn't interact withurlBase(qBittorrent's CSRF/Referer check is origin-based, not path-based), so I left it alone here, but it seemed worth mentioning in case it's the cause of a future report like "Test Connection works but adding a torrent fails."