MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveWebBaseUrl

Function resolveWebBaseUrl

apps/host-selfhost/src/config.ts:128–142  ·  view source on GitHub ↗
(port: number)

Source from the content-addressed store, hash-verified

126// poison those links (the request origin is only trusted for the CSRF/
127// `trustedOrigins` check, which is same-origin-safe; see better-auth.ts).
128const resolveWebBaseUrl = (port: number): string => {
129 const resolved = resolvePublicOrigin({
130 explicit: process.env.EXECUTOR_WEB_BASE_URL,
131 env: process.env,
132 });
133 if (resolved) return resolved;
134 const fallback = `http://localhost:${port}`;
135 // A deployed instance with no detectable origin mints localhost links — warn
136 // once (unless local dev/test) so the operator sets the variable.
137 if (!warnedNoPublicUrl && shouldWarnMissingPublicOrigin(process.env.NODE_ENV)) {
138 warnedNoPublicUrl = true;
139 console.warn(missingPublicOriginWarning({ varName: "EXECUTOR_WEB_BASE_URL", fallback }));
140 }
141 return fallback;
142};
143
144export const loadConfig = (): SelfHostConfig => {
145 const port = Number.parseInt(process.env.PORT ?? "4788", 10);

Callers 1

loadConfigFunction · 0.70

Calls 4

resolvePublicOriginFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected