fix(web): only use a public address on a fixed listener port (#1862)

Addresses Copilot review round 2. A reverse proxy routes a public address to
one stable port, so neither MCP_SANDBOX_FULL_ADDRESS nor
MCP_APP_ORIGIN_FULL_ADDRESS is used when the listener's port is OS-assigned:
an explicit 0, a config-time collision resolved to 0, or the EADDRINUSE
fallback. Validation warnings also stop echoing the URL path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HzuzRPJv7M8wGe3wyw5sSg
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-14 01:10:29 -04:00
commit 925461a043

View file

@ -94,14 +94,15 @@ function parsePublicUrl(raw: string): Parsed {
/**
* The value as it may appear in a log line. Never the raw string: the values
* refused for carrying credentials or a query are exactly the ones likely to
* hold a secret, and echoing them would leak what the check refused. Userinfo,
* query and fragment are dropped; an unparseable value is not echoed at all.
* refused for carrying credentials, a query or a path are exactly the ones
* likely to hold a secret, and echoing them would leak what the check refused.
* Only scheme and host are shown — that is enough to identify which address was
* refused — and an unparseable value is not echoed at all.
*/
export function describeForLog(raw: string): string {
try {
const u = new URL(raw);
return `"${u.protocol}${u.host ? `//${u.host}` : ""}${u.pathname}"`;
return `"${u.protocol}${u.host ? `//${u.host}` : ""}"`;
} catch {
return "(unparseable value, not echoed)";
}