mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
committed by
decolua
co-authored by
Cursor
parent
096491d8d7
commit
50ed79fe9e
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect, vi, afterEach } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
execSync: vi.fn(() => { throw new Error("not found"); }),
|
||||
}));
|
||||
|
||||
vi.mock("child_process", () => ({
|
||||
execSync: mocks.execSync,
|
||||
}));
|
||||
|
||||
import { getHeadroomStatus, isLoopbackHeadroomUrl } from "../../src/lib/headroom/detect.js";
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("headroom detect", () => {
|
||||
it("treats a reachable external proxy as running without local CLI", async () => {
|
||||
global.fetch = vi.fn(async () => new Response("ok", { status: 200 }));
|
||||
|
||||
const status = await getHeadroomStatus("http://headroom:8787");
|
||||
|
||||
expect(status.installed).toBe(false);
|
||||
expect(status.running).toBe(true);
|
||||
expect(status.localUrl).toBe(false);
|
||||
expect(status.canStart).toBe(false);
|
||||
expect(global.fetch).toHaveBeenCalledWith("http://headroom:8787/health", expect.any(Object));
|
||||
});
|
||||
|
||||
it("recognizes loopback URLs for managed local mode", () => {
|
||||
expect(isLoopbackHeadroomUrl("http://localhost:8787")).toBe(true);
|
||||
expect(isLoopbackHeadroomUrl("http://127.0.0.1:8787")).toBe(true);
|
||||
expect(isLoopbackHeadroomUrl("http://headroom:8787")).toBe(false);
|
||||
expect(isLoopbackHeadroomUrl("not-a-url")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user