Skip to content

Fix Torznab/Prowlarr download URL rewrite to avoid proxy double-wrapping on host aliases#647

Open
Copilot wants to merge 2 commits into
release/1.4.0from
copilot/fix-double-wraps-torrent-urls
Open

Fix Torznab/Prowlarr download URL rewrite to avoid proxy double-wrapping on host aliases#647
Copilot wants to merge 2 commits into
release/1.4.0from
copilot/fix-double-wraps-torrent-urls

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

Questarr started failing all torrent downloads after the Torznab rewrite logic began re-wrapping Prowlarr download links. When Prowlarr returned its own proxy URL but the hostname differed by alias (localhost vs 127.0.0.1), Questarr produced a doubly wrapped link parameter that Prowlarr rejected.

  • Torznab rewrite guard for existing Prowlarr proxy links

    • In server/torznab.ts, for Prowlarr-style indexers (/{id}/api):
      • If incoming link is already a Prowlarr proxy URL (/{id}/download with link query param), Questarr now rewrites only protocol/host to the configured indexer URL.
      • Questarr no longer rebuilds a new proxy URL in this case, preventing nested base64 encoding.
    • Existing behavior remains for true external/raw links: Questarr still constructs a Prowlarr proxy download URL.
  • Regression coverage for hostname alias case

    • Added test in server/__tests__/torznab.test.ts to cover:
      • Configured indexer host: localhost
      • Returned link host: 127.0.0.1
      • Expected: rewritten host with preserved original link payload (no double-wrap).
const isProwlarrProxyUrl =
  /^\/\d+\/download\/?$/i.test(linkUrl.pathname) && linkUrl.searchParams.has("link");

if (isProwlarrProxyUrl) {
  linkUrl.protocol = indexerUrlObj.protocol;
  linkUrl.host = indexerUrlObj.host;
  torznabItem.link = linkUrl.toString();
}

Copilot AI changed the title [WIP] Fix Prowlarr download URL double-wrapping issue Fix Torznab/Prowlarr download URL rewrite to avoid proxy double-wrapping on host aliases May 31, 2026
Copilot finished work on behalf of Doezer May 31, 2026 11:44
Copilot AI requested a review from Doezer May 31, 2026 11:44
@sonarqubecloud
Copy link
Copy Markdown

@Doezer
Copy link
Copy Markdown
Owner

Doezer commented May 31, 2026

/deploy tag=Prowlarr-host-rewrite

@Doezer Doezer marked this pull request as ready for review May 31, 2026 12:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76f6b4f2cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/torznab.ts
Comment on lines +334 to +335
const isProwlarrProxyUrl =
/^\/\d+\/download\/?$/i.test(linkUrl.pathname) && linkUrl.searchParams.has("link");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict proxy detection before skipping wrapping

When a Prowlarr-backed indexer returns a raw external download URL whose path happens to match /<digits>/download and includes a link query parameter, this new check classifies it as an existing Prowlarr proxy solely from the path/query. In that case Questarr rewrites the host to Prowlarr but skips the code that base64-wraps the original URL and adds the configured apikey, so downloads from trackers using that URL shape are sent to Prowlarr as malformed proxy requests instead of the intended raw external URL. The guard should also verify that the returned URL is actually from the configured Prowlarr host/known alias (and ideally the same indexer id) before taking this branch.

Useful? React with 👍 / 👎.

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.

torznab client double-wraps Prowlarr download URLs when host names alias (e.g. localhost vs 127.0.0.1)

2 participants