Skip to content

Direct downloads are served by the API server instead of delegating to a proxy node #326

Closed

Description

@fluxis

Summary

When downloading an item, the api server serves the response with the file download rather than pawning off to a proxy node.

s.domain.com/api/v1/direct-download?file_id=12345&token=abcdefg

Should be passing the download off to

srv01-proxy.domain.com/api/v1/direct-download?file_id=12345&token=abcdefg or something

Reply digest

When downloading an item, the central API server streams the file bytes itself (s.domain.com/api/v1/direct-download?...) rather than handing the download off to a configured proxy node (srv01-proxy.domain.com/...). Playback already delegates to proxy nodes; downloads never do, so the API server carries all download egress.

Code references

Verified present on origin/main as of 2026-07-07 (no download/proxy-node commits in the gap). Reads as an enhancement/feature-gap rather than a regression: playback delegates via PlanSession -> resp.StreamURL rewrite, but the download handler has no NodePlanner at all. Fix mirrors playback: give the download handler a NodePlanner/ProxyPool and 302-redirect to proxyNode.URL when healthy proxy nodes exist.

  • internal/api/handlers/downloads.go:45: DownloadHandler struct lacks a NodePlanner/proxy-pool dependency (unlike PlaybackHandler), so the download route can never delegate to a node
  • internal/api/handlers/downloads.go:424 (HandleDirectDownload): unconditionally streams via svc.ServeDirect; never issues a redirect/URL-rewrite to a proxy node
  • internal/downloads/service.go:849 (ServeDirect -> serveLocalFile -> http.ServeContent): always serves bytes locally; no nodepool import, no proxy-URL generation

Attachments

None.

Source

Imported from Discord:

Activity

  1. added theissue type on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions