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