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

Function resolveWebBaseUrl

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

Source from the content-addressed store, hash-verified

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