Skip to content

Custom HTTP transport

If your server sits behind an authenticating proxy (Cloudflare Access, Tailscale Funnel, an OAuth gateway), the Subsonic protocol alone is not enough — the proxy needs its own credentials before any Subsonic request reaches the server.

SwiftSonic exposes a custom transport seam so you can attach extra headers to every outgoing request without forking the client.

TODO: confirm the exact type name and constructor in 0.6.x. Likely CustomHeadersTransport under Sources/SwiftSonic/Transport/. Verify and update.

// TODO: replace with verified API surface
let transport = CustomHeadersTransport(headers: [
"CF-Access-Client-Id": "<your-client-id>",
"CF-Access-Client-Secret": "<your-client-secret>"
])
let config = ServerConfiguration(
host: "music.example.com",
username: "user",
password: "pass",
transport: transport
)
  • Cloudflare AccessCF-Access-Client-Id + CF-Access-Client-Secret service tokens.
  • Reverse proxies with auth headers (Authorization: Bearer ..., X-Auth-Token, etc.).
  • Per-tenant routing (X-Tenant-Id).

The custom transport injects request headers. It does not:

  • Handle response decoding (that stays with the client).
  • Implement OAuth flows (you supply already-issued tokens).
  • Replace the Subsonic auth (u=, t=, s= are still on the URL).

TODO: document whether the transport is composable (can a user chain custom-headers + retry + logging?) once the protocol surface is confirmed.