(port: number)
| 139 | // poison those links (the request origin is only trusted for the CSRF/ |
| 140 | // `trustedOrigins` check, which is same-origin-safe; see better-auth.ts). |
| 141 | const resolveWebBaseUrl = (port: number): string => { |
| 142 | const resolved = resolvePublicOrigin({ |
| 143 | explicit: process.env.EXECUTOR_WEB_BASE_URL, |
| 144 | env: process.env, |
| 145 | }); |
| 146 | if (resolved) return resolved; |
| 147 | const fallback = `http://localhost:${port}`; |
| 148 | // A deployed instance with no detectable origin mints localhost links — warn |
| 149 | // once (unless local dev/test) so the operator sets the variable. |
| 150 | if (!warnedNoPublicUrl && shouldWarnMissingPublicOrigin(process.env.NODE_ENV)) { |
| 151 | warnedNoPublicUrl = true; |
| 152 | console.warn(missingPublicOriginWarning({ varName: "EXECUTOR_WEB_BASE_URL", fallback })); |
| 153 | } |
| 154 | return fallback; |
| 155 | }; |
| 156 | |
| 157 | export const loadConfig = (): SelfHostConfig => { |
| 158 | const port = Number.parseInt(process.env.PORT ?? "4788", 10); |
no test coverage detected