fix(headroom): support Docker sidecar proxy

Treat configured Headroom proxy as running when its /health endpoint
responds, even if local headroom CLI is not installed. Dashboard
Start/Stop stays limited to local loopback proxies while external
Docker sidecars can be enabled via HEADROOM_URL.

Closes #1948

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Carmelo Campos
2026-06-21 17:45:27 +07:00
committed by decolua
co-authored by Cursor
parent 096491d8d7
commit 50ed79fe9e
8 changed files with 140 additions and 40 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { getAdapter } from "../driver.js";
import { parseJson, stringifyJson } from "../helpers/jsonCol.js";
const DEFAULT_MITM_ROUTER_BASE = "http://localhost:20128";
const DEFAULT_HEADROOM_URL = process.env.HEADROOM_URL || "http://localhost:8787";
const DEFAULT_SETTINGS = {
cloudEnabled: false,
@@ -35,7 +36,7 @@ const DEFAULT_SETTINGS = {
dnsToolEnabled: {},
rtkEnabled: true,
headroomEnabled: false,
headroomUrl: "http://localhost:8787",
headroomUrl: DEFAULT_HEADROOM_URL,
headroomCompressUserMessages: false,
cavemanEnabled: false,
cavemanLevel: "full",
+15 -2
View File
@@ -29,6 +29,9 @@ const EXTENDED_PATH = [...EXTRA_BINS, process.env.PATH || ""].filter(Boolean).jo
const PYTHON_CANDIDATES = ["python3.13", "python3.12", "python3.11", "python3.10", "python3", "python"];
const MIN_VERSION = [3, 10];
const HEADROOM_HEALTH_TIMEOUT_MS = 1500;
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]", "0.0.0.0"]);
export const DEFAULT_HEADROOM_URL = process.env.HEADROOM_URL || "http://localhost:8787";
// Detect whether the headroom CLI is installed and where its binary lives.
export function findHeadroomBinary() {
@@ -79,11 +82,21 @@ export async function probeProxyRunning(url) {
}
}
export function isLoopbackHeadroomUrl(url) {
try {
const parsed = new URL(url);
return LOOPBACK_HOSTS.has(parsed.hostname);
} catch {
return false;
}
}
// Aggregate status for the dashboard: installed, running, python interpreter.
export async function getHeadroomStatus(url) {
const path = findHeadroomBinary();
const python = findPython310();
const installed = Boolean(path);
const running = installed ? await probeProxyRunning(url) : false;
return { installed, path, running, python };
const running = await probeProxyRunning(url);
const localUrl = isLoopbackHeadroomUrl(url);
return { installed, path, running, python, localUrl, canStart: installed && localUrl };
}