Skip to content

feat(app): custom request headers for server connections - #67676

Open
biggestcookie wants to merge 3 commits into
anomalyco:devfrom
biggestcookie:custom-server-headers
Open

biggestcookie wants to merge 3 commits into
anomalyco:devfrom
biggestcookie:custom-server-headers

Conversation

@biggestcookie

@biggestcookie biggestcookie commented Dec 2, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #64673

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Ports the ability from the OpenCode mobile app to add custom request headers in the 'Add server' dialog in the desktop and web UI.
This allows clients to reach a server behind a gateway or reverse proxy that needs its own headers (such as service tokens, tenant IDs, Bearer auth).

When adding a server with the password method, the dialog now shows a Headers section below the password field. Add header appends a name/value row with a remove button. Rows are saved with the connection and sent on the API client, the health probe and the event stream.
The behavior is opt-in per connection, and nothing is sent until a header row is added.

Notes:

  • An existing or plugin-written connection is normalized at request time (trim, dedupe, drop unsendable rows) so it cannot throw or vanish silently.
  • An explicit Authorization row replaces the Basic header generated from the password.
  • Validation
    • Names must be HTTP tokens, and the Fetch forbidden request-header list (Host, Cookie, Content-Length, Origin, Proxy-*, Sec-*, …) is rejected. Values reject CR/LF/NUL and other control characters. Duplicate names are flagged case-insensitively. Empty rows are ignored, and a value without a name is flagged.
    • Some header names are silently dropped and some values throw in a browser, while a native client would send them. Instead of saving a row that only works on one surface, the form flags it under the row and blocks the connection until it is fixed.
  • Media: <video>/<audio> cannot send headers, so media falls back to the API download when a connection has custom headers.

How did you verify your code works?

  • In packages/app: bun typecheck and bun run typecheck:tsc pass, and bun run test passes (3,169 unit tests and 394 browser tests, 0 failures).
  • Manually: save a header on a connection and confirm it arrives on /api/info and on the /api/event stream.

Screenshots / recordings

Connect screen:

Connect to a server with a header row in the Headers section

Add server dialog:

Add server dialog with the Headers section

Related

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@biggestcookie
biggestcookie force-pushed the custom-server-headers branch 2 times, most recently from 43eba72 to 3eb43cf Compare December 4, 2026 18:57
Add request headers to the Add Server dialog and connect screen. In
password mode a Headers section lists name/value rows with a remove
action and a small Add header button, matching the mobile client.

Saved headers are sent on every request to the server (API client,
health checks, uploads), and an explicit Authorization header takes
precedence over the Basic auth generated from the password.

Refs anomalyco#64673
Reject header rows a browser cannot send: non-token names, the Fetch forbidden list, control characters in values, and case-insensitive duplicates. Each row explains the problem and blocks submit; the request path trims, deduplicates and drops unsendable rows so a stored or plugin-written entry cannot throw or vanish silently.

A saved authorization now replaces the generated Basic header regardless of case, and media falls back to the API download when the connection has custom headers.
Ports the header coverage the old stories had after upstream replaced them with Lab pages, and fixes the edit target those pages build now that ServerOriginal carries headers.
@biggestcookie
biggestcookie marked this pull request as ready for review December 4, 2026 19:14

This branch has not been deployed

No deployments
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.

[FEATURE]: Custom request headers when adding a server (desktop & web)

1 participant