(port: number)
| 161 | // poison those links (the request origin is only trusted for the CSRF/ |
| 162 | // `trustedOrigins` check, which is same-origin-safe; see better-auth.ts). |
| 163 | const resolveWebBaseUrl = (port: number): string => { |
| 164 | const resolved = resolvePublicOrigin({ |
| 165 | explicit: process.env.EXECUTOR_WEB_BASE_URL, |
| 166 | env: process.env, |
| 167 | }); |
| 168 | if (resolved) return resolved; |
| 169 | const fallback = `http://localhost:${port}`; |
| 170 | // A deployed instance with no detectable origin mints localhost links — warn |
| 171 | // once (unless local dev/test) so the operator sets the variable. |
| 172 | if (!warnedNoPublicUrl && shouldWarnMissingPublicOrigin(process.env.NODE_ENV)) { |
| 173 | warnedNoPublicUrl = true; |
| 174 | console.warn(missingPublicOriginWarning({ varName: "EXECUTOR_WEB_BASE_URL", fallback })); |
| 175 | } |
| 176 | return fallback; |
| 177 | }; |
| 178 | |
| 179 | export const loadConfig = (): SelfHostConfig => { |
| 180 | const port = Number.parseInt(process.env.PORT ?? "4788", 10); |
no test coverage detected