Skip to content

The agent that grows with you

feat(desktop): support remote gateway headers

tigercraft4fcef62ef72ff
diff --git a/apps/desktop/README.md b/apps/desktop/README.md
index 706611acb1a..9358965ce9c 100644
--- a/apps/desktop/README.md
+++ b/apps/desktop/README.md
@@ -147,6 +147,32 @@ In remote mode the gateway host is the execution boundary: agent tools,
terminal commands, and file operations run against the remote Hermes host, not
the computer displaying the Desktop UI.
+Remote gateways that sit behind an access proxy may require extra headers on
+every HTTP and WebSocket request. Until Settings exposes those fields, advanced
+deployments can add a `headers` object to Desktop's Electron
+`userData/connection.json` remote block:
+
+```json
+{
+ "mode": "remote",
+ "remote": {
+ "url": "https://hermes.example.com",
+ "authMode": "token",
+ "token": { "encoding": "safeStorage", "value": "..." },
+ "headers": {
+ "CF-Access-Client-Id": { "encoding": "safeStorage", "value": "..." },
+ "CF-Access-Client-Secret": { "encoding": "safeStorage", "value": "..." }
+ }
+ }
+}
+```
+
+Per-profile remote entries under `profiles[name].headers` use the same shape.
+Desktop applies these headers only to matching remote gateway requests, treats
+`https` and `wss` as the same gateway origin for WebSocket upgrades, and drops
+transport- or Hermes-managed header names such as `Authorization`, `Cookie`,
+`Host`, `Origin`, `Referer`, and `X-Hermes-Session-Token`.
+
Projects are the workspace abstraction. A project may own multiple folders,
repositories, worktrees, and sessions; a bare new chat remains detached unless
the user enters a project or configures a default project directory. Use the
diff --git a/apps/desktop/electron/connection-config.test.ts b/apps/desktop/electron/connection-config.test.ts
index 8d7ee891bb9..aeb9832bba9 100644
--- a/apps/desktop/electron/connection-config.test.ts
+++ b/apps/desktop/electron/connection-config.test.ts
@@ -31,6 +31,7 @@ import {
localProfileEntry,
modeIsRemoteLike,
normalizeRemoteBaseUrl,
+ normalizeRemoteHeaders,
normalizeSshConfig,
normAuthMode,
pathWithGlobalRemoteProfile,
@@ -38,6 +39,7 @@ import {
profileHasRemoteConnection,
profileRemoteOverride,
profileSshOverride,
+ remoteRequestMatchesBaseUrl,
resolveAuthMode,
resolveProfileBackendRoute,
resolveTestWsUrl,
@@ -63,6 +65,38 @@ test('normAuthMode coerces to token unless explicitly oauth', () => {
assert.equal(normAuthMode('weird'), 'token')
})
+test('normalizeRemoteHeaders keeps safe proxy headers and drops transport/auth headers', () => {
+ assert.deepEqual(
+ normalizeRemoteHeaders({
+ ' CF-Access-Client-Id ': { encoding: 'plain', value: 'id' },
+ 'CF-Access-Client-Secret': 'secret',
+ Authorization: { encoding: 'plain', value: 'bearer' },
+ Cookie: { encoding: 'plain', value: 'a=b' },
+ Host: { encoding: 'plain', value: 'example.com' },
+ 'X-Hermes-Session-Token': { encoding: 'plain', value: 'token' },
+ 'Bad Header': { encoding: 'plain', value: 'bad' },
+ Empty: { encoding: 'plain', value: '' }
+ }),
+ {
+ 'CF-Access-Client-Id': { encoding: 'plain', value: 'id' },
+ 'CF-Access-Client-Secret': { encoding: 'plain', value: 'secret' }
+ }
+ )
+})
+
+test('remoteRequestMatchesBaseUrl treats HTTPS and WSS as the same gateway origin', () => {
+ assert.equal(
+ remoteRequestMatchesBaseUrl(
+ 'wss://hermes.example.com/gateway/api/ws?ticket=abc',
+ 'https://hermes.example.com/gateway'
+ ),
+ true
+ )
+ assert.equal(remoteRequestMatchesBaseUrl('ws://hermes.example.com/api/ws', 'http://hermes.example.com'), true)
+ assert.equal(remoteRequestMatchesBaseUrl('wss://hermes.example.com/other/api/ws', 'https://hermes.example.com/gateway'), false)
+ assert.equal(remoteRequestMatchesBaseUrl('wss://other.example.com/gateway/api/ws', 'https://hermes.example.com/gateway'), false)
+})
+
// --- modeIsRemoteLike ---
test('modeIsRemoteLike is true for remote and cloud, false otherwise', () => {
@@ -115,6 +149,30 @@ test('profileRemoteOverride preserves an explicit oauth auth mode', () => {
assert.equal(profileRemoteOverride(config, 'coder').authMode, 'oauth')
})
+test('profileRemoteOverride preserves normalized remote headers', () => {
+ const config = {
+ profiles: {
+ coder: {
+ mode: 'remote',
+ url: 'https://x',
+ headers: {
+ 'CF-Access-Client-Id': { encoding: 'safeStorage', value: 'encrypted-id' },
+ Authorization: { encoding: 'plain', value: 'blocked' }
+ }
+ }
+ }
+ }
+
+ assert.deepEqual(profileRemoteOverride(config, 'coder'), {
+ url: 'https://x',
+ authMode: 'token',
+ token: undefined,
+ headers: {
+ 'CF-Access-Client-Id': { encoding: 'safeStorage', value: 'encrypted-id' }
+ }
+ })
+})
+
test('profileRemoteOverride treats a cloud entry as a remote override', () => {
// A 'cloud' per-profile entry resolves to the same remote backend a 'remote'
// entry would (Q6) — the override must be returned, not dropped.
diff --git a/apps/desktop/electron/connection-config.ts b/apps/desktop/electron/connection-config.ts
index eab233545c3..fc6c5278766 100644
--- a/apps/desktop/electron/connection-config.ts
+++ b/apps/desktop/electron/connection-config.ts
@@ -219,6 +219,80 @@ function normAuthMode(mode) {
return mode === 'oauth' ? 'oauth' : 'token'
}
+const REMOTE_HEADER_NAME_RE = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
+
+const FORBIDDEN_REMOTE_HEADER_NAMES = new Set([
+ 'authorization',
+ 'connection',
+ 'content-length',
+ 'content-type',
+ 'cookie',
+ 'host',
+ 'origin',
+ 'referer',
+ 'te',
+ 'trailer',
+ 'transfer-encoding',
+ 'upgrade',
+ 'x-hermes-session-token'
+])
+
+function normalizeRemoteHeaders(raw) {
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
+ return {}
+ }
+
+ const out = {}
+
+ for (const [name, secret] of Object.entries(raw)) {
+ const headerName = String(name || '').trim()
+ const lower = headerName.toLowerCase()
+
+ if (!headerName || !REMOTE_HEADER_NAME_RE.test(headerName) || FORBIDDEN_REMOTE_HEADER_NAMES.has(lower)) {
+ continue
+ }
+
+ if (typeof secret === 'string') {
+ const value = secret.trim()
+
+ if (value) {
+ out[headerName] = { encoding: 'plain', value }
+ }
+
+ continue
+ }
+
+ if (secret && typeof secret === 'object') {
+ const encoding = String((secret as any).encoding || '')
+ const value = String((secret as any).value || '')
+
+ if (value && (encoding === 'safeStorage' || encoding === 'plain' || !encoding)) {
+ out[headerName] = { encoding: encoding || 'plain', value }
+ }
+ }
+ }
+
+ return out
+}
+
+function remoteRequestMatchesBaseUrl(requestUrl, baseUrl) {
+ try {
+ const request = new URL(requestUrl)
+ const base = new URL(baseUrl)
+ const basePath = base.pathname.replace(/\/+$/, '')
+ const requestProtocol = request.protocol === 'ws:' ? 'http:' : request.protocol === 'wss:' ? 'https:' : request.protocol
+ const baseProtocol = base.protocol === 'ws:' ? 'http:' : base.protocol === 'wss:' ? 'https:' : base.protocol
+
+ if (requestProtocol !== baseProtocol || request.host !== base.host) {
+ return false
+ }
+
+ return !basePath || request.pathname === basePath || request.pathname.startsWith(`${basePath}/`)
+ } catch {
+ return false
+ }
+}
+
// True for connection modes that resolve to a REMOTE backend. 'cloud' is a
// Hermes Cloud connection (cloud-auto-discovery Q3/Q6): it carries a
// remote-shaped block and reuses the entire remote connect/probe/reconnect
@@ -367,8 +441,8 @@ function hostLabelFromBaseUrl(baseUrl) {
*
* The config may carry a `profiles` map keyed by name; an entry counts as an
* override only with a remote-like `mode` (remote or cloud) and a non-empty
- * `url`. Pure: `token` is the raw stored secret; main.ts decrypts it. Returns
- * `{ url, authMode, token } | null`.
+ * `url`. Pure: `token` and `headers` are raw stored secrets; main.ts decrypts
+ * them. Returns `{ url, authMode, token, headers } | null`.
*/
function profileRemoteOverride(config, profile) {
const key = connectionScopeKey(profile)
@@ -384,7 +458,14 @@ function profileRemoteOverride(config, profile) {
return null
}
- return { url, authMode: normAuthMode(entry.authMode), token: entry.token }
+ const headers = normalizeRemoteHeaders(entry.headers)
+
+ return {
+ url,
+ authMode: normAuthMode(entry.authMode),
+ token: entry.token,
+ ...(Object.keys(headers).length > 0 ? { headers } : {})
+ }
}
export interface ProfileRouteOptions {
@@ -690,6 +771,8 @@ export {
localProfileEntry,
modeIsRemoteLike,
normalizeRemoteBaseUrl,
+ normalizeRemoteHeaders,
+ remoteRequestMatchesBaseUrl,
normalizeSshConfig,
normAuthMode,
pathWithGlobalRemoteProfile,
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 913e877f27a..ee75189a96f 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -71,6 +71,7 @@ import {
localProfileEntry,
modeIsRemoteLike,
normalizeRemoteBaseUrl,
+ normalizeRemoteHeaders,
normalizeSshConfig,
normAuthMode,
pathWithGlobalRemoteProfile,
@@ -78,6 +79,7 @@ import {
profileHasRemoteConnection,
profileRemoteOverride,
profileSshOverride,
+ remoteRequestMatchesBaseUrl,
resolveAuthMode,
resolveProfileBackendRoute,
resolveTestWsUrl,
@@ -1232,6 +1234,8 @@ let connectionConfigCache = null
let connectionConfigCacheMtime = null
let connectionRegistryCache = null
let connectionRegistryCacheMtime = null
+let remoteHeaderRulesInstalled = false
+const remoteWsHeadersByUrl = new Map<string, Record<string, string>>()
const hermesLog = []
const previewWatchers = new Map()
let previewShortcutActive = false
@@ -4682,6 +4686,8 @@ function fetchJson(url, token, options: any = {}) {
{
method: options.method || 'GET',
headers: {
+ ...headersForRemoteRequest(url),
+ ...(options.headers || {}),
'Content-Type': contentType,
'X-Hermes-Session-Token': token,
// RFC 8252 native flow authenticates the gated gateway with a bearer
@@ -4842,6 +4848,8 @@ function fetchPublicJson(url, options: any = {}) {
{
method: options.method || 'GET',
headers: {
+ ...headersForRemoteRequest(url),
+ ...(options.headers || {}),
'Content-Type': 'application/json',
...(body ? { 'Content-Length': String(body.length) } : {})
}
@@ -5531,6 +5539,16 @@ function closePreviewWatchers() {
}
}
+function requestOptionsWithHeaders(options: any = {}, headers = {}) {
+ return {
+ ...options,
+ headers: {
+ ...headers,
+ ...(options.headers || {})
+ }
+ }
+}
+
/** Watch a DIRECTORY for entry churn (folders appearing/vanishing) — the
* disk-plugin door's "new plugin folder" signal, replacing the renderer's 5s
* readdir poll. Same registry + change channel as the preview file watchers
@@ -5577,7 +5595,7 @@ function watchDirectory(rawDir) {
// strict guard — backends predating /api/auth/providers are unaffected.
const gatewayAuthProvidersCache = new Map<string, any[]>()
-async function gatewayAuthProviders(baseUrl) {
+async function gatewayAuthProviders(baseUrl, headers = {}) {
const cached = gatewayAuthProvidersCache.get(baseUrl)
if (cached) {
@@ -5587,7 +5605,10 @@ async function gatewayAuthProviders(baseUrl) {
let providers = []
try {
- const body = (await fetchPublicJson(`${baseUrl}/api/auth/providers`, { timeoutMs: 8_000 })) as any
+ const body = (await fetchPublicJson(
+ `${baseUrl}/api/auth/providers`,
+ requestOptionsWithHeaders({ timeoutMs: 8_000 }, headers)
+ )) as any
if (Array.isArray(body?.providers)) {
providers = body.providers
@@ -5595,12 +5616,12 @@ async function gatewayAuthProviders(baseUrl) {
.map(p => ({ name: String(p.name || ''), supportsPassword: Boolean(p.supports_password) }))
.filter(p => p.name)
}
+
+ gatewayAuthProvidersCache.set(baseUrl, providers)
} catch {
// Optional metadata — an unreadable list keeps the strict guard.
}
- gatewayAuthProvidersCache.set(baseUrl, providers)
-
return providers
}
@@ -5641,15 +5662,17 @@ async function buildReadinessHealthProbe(baseUrl, authMode, token) {
return { probeHealth: fetchPublicJson, probeIsCredentialed: false }
}
-async function waitForHermes(baseUrl, token, signal?, authMode?) {
+async function waitForHermes(baseUrl, token, signal?, authMode?, headers = {}) {
const { probeHealth, probeIsCredentialed } = await buildReadinessHealthProbe(baseUrl, authMode, token)
return waitForHermesReady(baseUrl, {
token,
signal,
fetchPublicJson,
- fetchJson: probeIsCredentialed ? (url, _token, options) => probeHealth(url, options) : fetchJson,
- probeHealth,
+ fetchJson: probeIsCredentialed
+ ? (url, _token, options = {}) => probeHealth(url, requestOptionsWithHeaders(options, headers))
+ : fetchJson,
+ probeHealth: (url, options = {}) => probeHealth(url, requestOptionsWithHeaders(options, headers)),
probeIsCredentialed
})
}
@@ -6718,6 +6741,10 @@ function fetchJsonViaOauthSession(url, options: any = {}) {
setJsonRequestHeaders(request)
+ for (const [name, value] of Object.entries({ ...headersForRemoteRequest(url), ...(options.headers || {}) })) {
+ request.setHeader(name, String(value))
+ }
+
let timedOut = false
const timer = setTimeout(() => {
@@ -7155,7 +7182,7 @@ async function saveGatewayFileViaDataUrl(connection, profile, filePath, ctx: any
// falling back to the OAuth cookie partition otherwise.
// Throws (with statusCode 401) if the session cookie is missing/expired —
// callers treat that as "needs re-login".
-async function mintGatewayWsTicket(baseUrl) {
+async function mintGatewayWsTicket(baseUrl, headers = {}) {
// Native flow: mint the ticket with the bearer token, no cookie involved.
const nativeAt = await ensureNativeAccessToken(baseUrl).catch(() => null)
@@ -7163,7 +7190,8 @@ async function mintGatewayWsTicket(baseUrl) {
const body = (await fetchJson(`${baseUrl}/api/auth/ws-ticket`, null, {
method: 'POST',
timeoutMs: 8_000,
- bearer: nativeAt
+ bearer: nativeAt,
+ headers
})) as any
const ticket = body?.ticket
@@ -7177,7 +7205,8 @@ async function mintGatewayWsTicket(baseUrl) {
const body = (await fetchJsonViaOauthSession(`${baseUrl}/api/auth/ws-ticket`, {
method: 'POST',
- timeoutMs: 8_000
+ timeoutMs: 8_000,
+ headers
})) as any
const ticket = body?.ticket
@@ -7205,12 +7234,17 @@ async function freshGatewayWsUrl(profile) {
const connection = await ensureBackend(profile)
if (connection.authMode === 'oauth') {
- const ticket = await mintGatewayWsTicket(connection.baseUrl)
+ const ticket = await mintGatewayWsTicket(connection.baseUrl, connection.headers)
+ const wsUrl = buildGatewayWsUrlWithTicket(connection.baseUrl, ticket)
- return buildGatewayWsUrlWithTicket(connection.baseUrl, ticket)
+ rememberRemoteWsHeaders(wsUrl, connection.headers)
+
+ return wsUrl
}
// Local/token: the cached wsUrl already carries the (long-lived) token.
+ rememberRemoteWsHeaders(connection.wsUrl, connection.headers)
+
return connection.wsUrl
}
@@ -7777,6 +7811,78 @@ function decryptDesktopSecret(secret) {
return value
}
+function decryptRemoteHeaders(headers) {
+ const normalized = normalizeRemoteHeaders(headers)
+ const out = {}
+
+ for (const [name, secret] of Object.entries(normalized)) {
+ const value = decryptDesktopSecret(secret)
+
+ if (value) {
+ out[name] = value
+ }
+ }
+
+ return out
+}
+
+function rememberRemoteWsHeaders(wsUrl, headers = {}) {
+ if (!wsUrl || Object.keys(headers).length === 0) {
+ return
+ }
+
+ remoteWsHeadersByUrl.set(String(wsUrl), headers as Record<string, string>)
+
+ while (remoteWsHeadersByUrl.size > 100) {
+ const oldest = remoteWsHeadersByUrl.keys().next().value
+
+ if (!oldest) {
+ break
+ }
+
+ remoteWsHeadersByUrl.delete(oldest)
+ }
+}
+
+function headersForRemoteRequest(requestUrl) {
+ const exactWsHeaders = remoteWsHeadersByUrl.get(String(requestUrl))
+
+ if (exactWsHeaders && Object.keys(exactWsHeaders).length > 0) {
+ return exactWsHeaders
+ }
+
+ const config = readDesktopConnectionConfig()
+
+ if (modeIsRemoteLike(config.mode) && config.remote?.url) {
+ const headers = decryptRemoteHeaders(config.remote.headers)
+
+ if (Object.keys(headers).length > 0 && remoteRequestMatchesBaseUrl(requestUrl, config.remote.url)) {
+ return headers
+ }
+ }
+
+ return {}
+}
+
+function installRemoteHeaderRules() {
+ if (remoteHeaderRulesInstalled) {
+ return
+ }
+
+ remoteHeaderRulesInstalled = true
+ session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
+ const headers = headersForRemoteRequest(details.url)
+
+ if (Object.keys(headers).length === 0) {
+ callback({})
+
+ return
+ }
+
+ callback({ requestHeaders: { ...details.requestHeaders, ...headers } })
+ })
+}
+
// Validate + normalize the per-profile remote overrides map read from disk.
// Drops malformed names/entries and keeps only the recognized fields so a
// hand-edited or stale connection.json can't inject junk into resolution.
@@ -7815,6 +7921,7 @@ function sanitizeConnectionProfiles(raw: Record<string, any>) {
url?: string
authMode?: string
token?: object
+ headers?: object
org?: string
savedSsh?: object
} = {
@@ -7841,6 +7948,12 @@ function sanitizeConnectionProfiles(raw: Record<string, any>) {
cleaned.token = entry.token
}
+ const headers = normalizeRemoteHeaders((entry as any).headers)
+
+ if (Object.keys(headers).length > 0) {
+ cleaned.headers = headers
+ }
+
// Preserve the Hermes Cloud org tag on cloud-mode entries so Settings can
// reopen into the same org for a per-profile cloud connection.
if (cleaned.mode === 'cloud') {
@@ -8212,17 +8325,23 @@ async function sanitizeDesktopConnectionConfig(config = readDesktopConnectionCon
// `org` (optional) is the Hermes Cloud org slug/id the instance was discovered
// under — persisted so Settings can reopen into the same org; omitted from the
// block when empty so plain remote connections stay unchanged.
-function buildRemoteBlock(remoteUrl, authMode, token, org?: string) {
+function buildRemoteBlock(remoteUrl, authMode, token, org?: string, headers?: object) {
if (authMode !== 'oauth' && !decryptDesktopSecret(token)) {
throw new Error('Remote gateway session token is required.')
}
- const block: { url: string; authMode: string; token: object; org?: string } = {
+ const block: { url: string; authMode: string; token: object; headers?: object; org?: string } = {
url: normalizeRemoteBaseUrl(remoteUrl),
authMode,
token
}
+ const remoteHeaders = normalizeRemoteHeaders(headers)
+
+ if (Object.keys(remoteHeaders).length > 0) {
+ block.headers = remoteHeaders
+ }
+
const orgValue = typeof org === 'string' ? org.trim() : ''
if (orgValue) {
@@ -8262,6 +8381,9 @@ function coerceDesktopConnectionConfig(input: any = {}, existing = readDesktopCo
const cloudOrg = mode === 'cloud' ? String(input.cloudOrg ?? existingBlock.org ?? '').trim() : ''
const incomingToken = typeof input.remoteToken === 'string' ? input.remoteToken.trim() : ''
+ const remoteHeaders =
+ input.remoteHeaders && typeof input.remoteHeaders === 'object' ? input.remoteHeaders : existingBlock.headers
+
// Persist decision lives in hardening.resolvePersistedRemoteToken so the
// IPC-propagation seam (allowPlainTextToken → encryptDesktopSecret opt-in) is
// covered by a focused regression test. Pass allowPlainText through RAW — the
@@ -8298,7 +8420,10 @@ function coerceDesktopConnectionConfig(input: any = {}, existing = readDesktopCo
const profiles = { ...(existing.profiles || {}) }
if (remoteLike) {
- profiles[key] = { mode, ...buildRemoteBlock(remoteUrl, authMode, nextToken, cloudOrg) }
+ profiles[key] = {
+ mode,
+ ...buildRemoteBlock(remoteUrl, authMode, nextToken, cloudOrg, remoteHeaders)
+ }
} else {
const localEntry = localProfileEntry(rawExistingBlock)
@@ -8317,7 +8442,7 @@ function coerceDesktopConnectionConfig(input: any = {}, existing = readDesktopCo
}
const nextRemote = remoteLike
- ? buildRemoteBlock(remoteUrl, authMode, nextToken, cloudOrg)
+ ? buildRemoteBlock(remoteUrl, authMode, nextToken, cloudOrg, remoteHeaders)
: existingMode === 'ssh'
? rawExistingBlock
: { url: remoteUrl ? normalizeRemoteBaseUrl(remoteUrl) : remoteUrl, authMode, token: nextToken }
@@ -8368,9 +8493,11 @@ async function buildRemoteConnection(
source,
remoteHost?,
remoteKind = 'url',
- remoteIdentity?
+ remoteIdentity?,
+ headers?
) {
const baseUrl = normalizeRemoteBaseUrl(rawUrl)
+ const remoteHeaders = decryptRemoteHeaders(headers)
// For token/oauth remotes the meaningful host is the real backend URL; for
// SSH remotes the caller passes the entered/resolved host explicitly (the
// baseUrl is a 127.0.0.1 tunnel and would be useless in the pill).
@@ -8394,7 +8521,7 @@ async function buildRemoteConnection(
// the stored bearer.
if (
!oauthSessionIsLive(hasNativeSession(baseUrl), await hasLiveOauthSession(baseUrl)) &&
- oauthGuardMayHardFail(await gatewayAuthProviders(baseUrl))
+ oauthGuardMayHardFail(await gatewayAuthProviders(baseUrl, remoteHeaders))
) {
const err = new Error(
'Remote Hermes gateway uses OAuth, but you are not signed in. ' +
@@ -8408,7 +8535,7 @@ async function buildRemoteConnection(
let ticket
try {
- ticket = await mintGatewayWsTicket(baseUrl)
+ ticket = await mintGatewayWsTicket(baseUrl, remoteHeaders)
} catch (error) {
throw gatewayTicketFailure(
error,
@@ -8417,6 +8544,10 @@ async function buildRemoteConnection(
)
}
+ const wsUrl = buildGatewayWsUrlWithTicket(baseUrl, ticket)
+
+ rememberRemoteWsHeaders(wsUrl, remoteHeaders)
+
return {
baseUrl,
mode: 'remote',
@@ -8425,9 +8556,10 @@ async function buildRemoteConnection(
remoteHost: host || undefined,
remoteIdentity,
remoteKind,
+ headers: remoteHeaders,
// No static token in OAuth mode; REST is cookie-authed via the partition.
token: null,
- wsUrl: buildGatewayWsUrlWithTicket(baseUrl, ticket)
+ wsUrl
}
}
@@ -8438,6 +8570,10 @@ async function buildRemoteConnection(
)
}
+ const wsUrl = buildGatewayWsUrl(baseUrl, token)
+
+ rememberRemoteWsHeaders(wsUrl, remoteHeaders)
+
return {
baseUrl,
mode: 'remote',
@@ -8446,8 +8582,9 @@ async function buildRemoteConnection(
remoteHost: host || undefined,
remoteIdentity,
remoteKind,
+ headers: remoteHeaders,
token,
- wsUrl: buildGatewayWsUrl(baseUrl, token)
+ wsUrl
}
}
@@ -8786,7 +8923,9 @@ async function resolveRemoteBackend(profile) {
token,
'profile',
undefined,
- config.profiles?.[connectionScopeKey(profile)]?.mode === 'cloud' ? 'cloud' : 'url'
+ config.profiles?.[connectionScopeKey(profile)]?.mode === 'cloud' ? 'cloud' : 'url',
+ undefined,
+ override.headers
)
}
@@ -8832,7 +8971,9 @@ async function resolveRemoteBackend(profile) {
token,
'settings',
undefined,
- config.mode === 'cloud' ? 'cloud' : 'url'
+ config.mode === 'cloud' ? 'cloud' : 'url',
+ undefined,
+ config.remote?.headers
)
}
@@ -8891,13 +9032,13 @@ async function requestJsonForProfile(profile: string, path: string, method: stri
const nativeAt = await ensureNativeAccessToken(conn.baseUrl).catch(() => null)
if (nativeAt) {
- return fetchJson(url, null, { ...opts, bearer: nativeAt })
+ return fetchJson(url, null, { ...opts, bearer: nativeAt, headers: conn.headers })
}
- return fetchJsonViaOauthSession(url, opts)
+ return fetchJsonViaOauthSession(url, { ...opts, headers: conn.headers })
}
- return fetchJson(url, conn.token, opts)
+ return fetchJson(url, conn.token, { ...opts, headers: conn.headers })
}
async function probeRemoteAuthMode(rawUrl) {
@@ -9611,7 +9752,7 @@ async function spawnPoolBackend(profile, entry, opts: { forceLocal?: boolean; po
const remote = opts.forceLocal ? null : await resolveRemoteBackend(profile)
if (remote) {
- await waitForHermes(remote.baseUrl, remote.token, undefined, remote.authMode)
+ await waitForHermes(remote.baseUrl, remote.token, undefined, remote.authMode, remote.headers)
// Recorded on the entry so revalidation can probe this descriptor without
// awaiting connectionPromise, which may still be pending for a sibling.
@@ -9921,7 +10062,7 @@ async function startHermes() {
}
await advanceBootProgress('backend.remote', `Connecting to remote Hermes backend at ${remote.baseUrl}`, 24)
- await waitForHermes(remote.baseUrl, remote.token, undefined, remote.authMode)
+ await waitForHermes(remote.baseUrl, remote.token, undefined, remote.authMode, remote.headers)
// Second async boundary: the health probe itself can outlive the
// attempt. A late success here must not publish a stale descriptor.
@@ -14491,6 +14632,7 @@ app.whenReady().then(() => {
installDownloadHandling()
registerMediaProtocol()
installEmbedReferer()
+ installRemoteHeaderRules()
registerDeepLinkProtocol()
ensureWslWindowsFonts()
configureSpellChecker()