fix: normalize wildcard gateway URLs for Codex

This commit is contained in:
2026-07-20 10:01:19 +08:00
parent 31e673f777
commit 14fae29618
6 changed files with 237 additions and 38 deletions
+6
View File
@@ -8,6 +8,8 @@ import os from "node:os";
import path from "node:path";
import { spawn } from "node:child_process";
import { getGatewayBaseUrl } from "./admin-lib.mjs";
const scriptsRoot = import.meta.dirname;
const launchScript = path.join(scriptsRoot, "launch-ui.sh");
const restoreScript = path.join(scriptsRoot, "restore-codex-config.sh");
@@ -122,6 +124,10 @@ async function run() {
const gatewayPort = await getFreePort();
const gatewayBaseUrl = `http://127.0.0.1:${gatewayPort}`;
const upstreamBaseUrl = `http://127.0.0.1:${upstreamPort}`;
assert(
getGatewayBaseUrl("0.0.0.0", gatewayPort) === gatewayBaseUrl,
"Wildcard listener must normalize to loopback for local gateway URLs",
);
await mkdir(codexDir, { recursive: true });
await writeFile(