π OpenHands: AI-Driven Development
fix: use IPv4 loopback for local proxy targets (#16290)
YUN GU0ffcb659d1d4
diff --git a/__tests__/scripts/dev-with-automation.test.ts b/__tests__/scripts/dev-with-automation.test.tsindex fb23610ea6..1c8c504ace 100644--- a/__tests__/scripts/dev-with-automation.test.ts+++ b/__tests__/scripts/dev-with-automation.test.ts@@ -480,7 +480,7 @@ describe("stack mode routing", () => {});});- it("routes only agent-server and automation in backend-only mode", async () => {+ it("routes only local services through IPv4 in backend-only mode", async () => {const config = await buildConfig({ backendOnly: true },envWithIsolatedKeyPath(),@@ -494,19 +494,19 @@ describe("stack mode routing", () => {const routes = getLocalServiceRoutes(config);expect(routes).toContainEqual(["/api/automation",- `http://localhost:${config.autoBackendPort}`,+ `http://127.0.0.1:${config.autoBackendPort}`,]);expect(routes).toContainEqual(["/api",- `http://localhost:${config.agentServerPort}`,+ `http://127.0.0.1:${config.agentServerPort}`,]);const routeArgs = buildRouteArgs(routes);expect(routeArgs).toContain(- `/api/automation=http://localhost:${config.autoBackendPort}`,+ `/api/automation=http://127.0.0.1:${config.autoBackendPort}`,);expect(routeArgs).toContain(- `/server_info=http://localhost:${config.agentServerPort}`,+ `/server_info=http://127.0.0.1:${config.agentServerPort}`,);expect(routeArgs).not.toContain("--default");});diff --git a/scripts/dev-with-automation.mjs b/scripts/dev-with-automation.mjsindex f54a45d446..bfdf5f270c 100644--- a/scripts/dev-with-automation.mjs+++ b/scripts/dev-with-automation.mjs@@ -682,16 +682,17 @@ const AGENT_SERVER_ROUTE_PREFIXES = [function getLocalServiceRoutes(config) {const routes = [];+ // These services bind to IPv4 loopback, but localhost can resolve to ::1.if (config.launchAutomation) {routes.push([AUTOMATION_ROUTE_PREFIX,- `http://localhost:${config.autoBackendPort}`,+ `http://127.0.0.1:${config.autoBackendPort}`,]);}if (config.launchAgentServer) {for (const prefix of AGENT_SERVER_ROUTE_PREFIXES) {- routes.push([prefix, `http://localhost:${config.agentServerPort}`]);+ routes.push([prefix, `http://127.0.0.1:${config.agentServerPort}`]);}}