Skip to content

fix: plumb literal headers through Helper HTTP requests#258

Merged
ethanndickson merged 2 commits into
mainfrom
ethan/plumb-headers-to-helper
Jun 22, 2026
Merged

fix: plumb literal headers through Helper HTTP requests#258
ethanndickson merged 2 commits into
mainfrom
ethan/plumb-headers-to-helper

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

Summary

The Helper process (Coder-DesktopHelper/Manager.swift) makes two HTTP requests to the Coder server during Manager.init that were not attaching configured literal headers. Users behind reverse proxies like Cloudflare Access see the VPN fail immediately after /api/v2/users/me succeeds (which runs in the App process where headers are correctly plumbed).

Changes

Manager.swift

  • Pass cfg.literalHeaders to the Client used for buildInfo() (line 44).
  • Pass cfg.literalHeaders to download() for the binary fetch (lines 67-72).

VPNLib/Download.swift

  • Add headers: [HTTPHeader] parameter (defaulting to []) to both the public download() function and the internal DownloadManager.download() method.
  • Apply headers to the URLRequest before the If-None-Match ETag header.
  • Add import CoderSDK for the HTTPHeader type.

Why this fixes the reported issue

  1. App calls users/me with headers -> succeeds (App process, state.client has headers)
  2. VPN starts -> Helper's Manager.init() runs
  3. Helper calls buildInfo() without headers -> blocked by Cloudflare Access (returns HTML)
  4. Client fails to parse HTML as JSON -> VPN startup aborts

After this fix, both buildInfo() and the binary download include the literal headers configured in Desktop settings.

Note

There is a remaining gap: SDWebImage icon fetches (WorkspaceAppIcon.swift) also don't include literal headers. This is cosmetic (broken icons, not broken VPN) and can be addressed separately.

Generated by Coder Agents (on behalf of @ethanndickson) This PR was created by Coder's AI coding agents. Please review carefully.

The Helper process makes two HTTP requests to the Coder server during
Manager.init that were not attaching configured literal headers:

1. Client(url:) for buildInfo() had no headers, so reverse proxies like
   Cloudflare Access would block the request.
2. download() for the coder binary used a plain URLSession with no headers.

Both call sites now pass cfg.literalHeaders. The download() function in
VPNLib/Download.swift is extended to accept and apply headers to the
URLRequest.
@ethanndickson ethanndickson marked this pull request as ready for review June 22, 2026 04:32

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

Copy link
Copy Markdown

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: a075a2f253

ℹ️ 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 Coder-Desktop/VPNLib/Download.swift Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 62aa78f8a7

ℹ️ 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".

@ethanndickson ethanndickson requested a review from jakehwll June 22, 2026 07:00

@matifali matifali left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't tested but the code changes look straightforward to me.

Maybe we should ask the user to test the pre-release version before cut a patch.

@ethanndickson

Copy link
Copy Markdown
Member Author

Yep, that's the plan

@ethanndickson ethanndickson merged commit 420204c into main Jun 22, 2026
@ethanndickson ethanndickson deleted the ethan/plumb-headers-to-helper branch June 22, 2026 07:29
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.

3 participants