Description
The client proxy copied the calling app's Referer and Origin headers onto the request it sends to qBittorrent. qBittorrent's WebUI CSRF check answers 401 when either header names a host other than its own, so an app that sends a Referer (the BookOrbit "Test connection" button, for example) could not use a client proxy URL, while apps that send none (Lidarr) worked.
rewriteRequest now deletes both headers from the outbound request, right after applyAuthHeaders. qui is the qBittorrent client here and its own API calls send neither header, so proxied calls now look the same to qBittorrent. RetryTransport clones that outbound request for every attempt, so a request replayed after a session refresh also goes out without them.
TestProxyDropsClientRefererAndOrigin sends requests through the handler to a test upstream that returns 401 on any Referer or Origin. It covers a Referer, a foreign Origin, no header, and a Referer on a request that gets the 403 of an expired session and is replayed after re-login. On develop the three header cases fail with 401.
Fixes #3167
How has this been tested?
No live run against a real qBittorrent instance. The closest check is the handler test above, whose upstream rejects the headers the way the CSRF check does.
Performance
No performance risk. Two header deletes per proxied request, no new allocations or I/O.
Checklist
- My PR title follows the Conventional Commits format (it becomes the squashed commit message)
- If this changes the database schema, I have added migrations for both SQLite and PostgreSQL
- I completed the mandatory performance checks and recorded the outcome in Performance
AI disclosure
Yes. The fix and test were written with Claude Code (Claude Opus) from the issue brief. I confirmed the new test fails without the fix, and ran go test -count=1 ./internal/proxy/, go vet and golangci-lint on the package.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
63d6062b-aeba-4af5-8e3b-66f86c30bb22📥 Commits
Reviewing files that changed from the base of the PR and between 332a5a5181816ab00cab424e362253d3e01cd09f and c7e618f23cf7c0b9a02a653c44a15676e43861c8.
📒 Files selected for processing: 2
internal/proxy/handler.gointernal/proxy/handler_test.goIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
📝 Walkthrough
The proxy now removes
RefererandOriginfrom outbound requests to qBittorrent. A new test covers requests with either header, requests without those headers, and a request replayed after an initial 403 response.Priority: ➖ Normal
Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
c7e61Proxied requests to qBittorrent no longer carry the calling app's Referer or Origin, which avoids 401 rejections from foreign hosts. The change is small and covered by a handler test. No concrete merge risk was identified.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.