fix(runtime): eliminate hardcoded 20128 port remnants and make loopback URLs dynamic (#13533)

* fix(runtime): eliminate hardcoded 20128 port remnants and make loopback URLs dynamic

- Make model assessment probe base URL resolve dynamically from getRuntimePorts() / env
- Support dynamic loopback in traffic inspector replay route and MITM handlers
- Make WebSocket live server allowlist dynamically include runtime PORT/DASHBOARD_PORT loopback origins
- Update CLI tools config/apply/letta-settings and tool-detector to adapt to configured runtime port
- Update client UI components (EndpointPageClient, ApiExplorerClient, RelayProxyClient) to use current window origin or dynamic port
- Make resolveOmniRouteBaseUrl, useDisplayBaseUrl, and wellKnown.ts respect configured port
- Update package.json electron:dev wait-on to use ${PORT:-20128}
- Add test coverage for custom port in resolveOmniRouteBaseUrl and liveServerAllowList
- Add changelog fragment for PR #13533

* fix(runtime): complete the truncated fallback comment in wellKnown.ts

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
ggdayup
2026-09-19 11:04:02 +08:00
committed by GitHub
parent bf0f213cf0
commit d715190bb0
25 changed files with 139 additions and 45 deletions

View File

@@ -209,7 +209,11 @@ export function resolveDisplayBaseUrl(
return joinOriginAndBasePath(configuredUrl, basePath);
}
const fallback = currentOrigin ?? configuredUrl ?? DEFAULT_DISPLAY_BASE_URL;
const portFallback =
typeof process !== "undefined" && (process.env.NEXT_PUBLIC_PORT || process.env.PORT)
? `http://localhost:${process.env.NEXT_PUBLIC_PORT || process.env.PORT}`
: DEFAULT_DISPLAY_BASE_URL;
const fallback = currentOrigin ?? configuredUrl ?? portFallback;
return joinOriginAndBasePath(fallback, basePath);
}

View File

@@ -4,6 +4,9 @@ type OmniRouteBaseUrlEnv = {
OMNIROUTE_BASE_URL?: string;
BASE_URL?: string;
NEXT_PUBLIC_BASE_URL?: string;
PORT?: string | number;
API_PORT?: string | number;
DASHBOARD_PORT?: string | number;
};
function normalizeBaseUrl(value?: string): string | null {
@@ -13,11 +16,14 @@ function normalizeBaseUrl(value?: string): string | null {
}
export function resolveOmniRouteBaseUrl(env: OmniRouteBaseUrlEnv = process.env): string {
const port = env.PORT || env.API_PORT || env.DASHBOARD_PORT;
const fallback = port ? `http://localhost:${port}` : DEFAULT_OMNIROUTE_BASE_URL;
return (
normalizeBaseUrl(env.OMNIROUTE_BASE_URL) ||
normalizeBaseUrl(env.BASE_URL) ||
normalizeBaseUrl(env.NEXT_PUBLIC_BASE_URL) ||
DEFAULT_OMNIROUTE_BASE_URL
fallback
);
}