feat(portal): allow PORTAL_APEX_HOSTS env to extend APEX_HOSTS (#15)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 10m17s
ci / e2e (push) Has been skipped
ci / image (push) Has been skipped

This commit was merged in pull request #15.
This commit is contained in:
2026-06-10 12:05:51 +00:00
parent 0862420e7c
commit 5856c1c732
+14 -1
View File
@@ -11,7 +11,20 @@ export type HostMatch =
| { kind: "unknown" };
// Longest-first so `stage.breakpilot.com` is matched before `breakpilot.com`.
const APEX_HOSTS = ["stage.breakpilot.com", "breakpilot.com", "localhost"];
// Built-ins cover dev (localhost) + the canonical breakpilot.com targets.
// PORTAL_APEX_HOSTS is a comma-separated env override for per-environment
// hosts (e.g. portal-dev.meghsakha.com while breakpilot.com isn't registered).
const APEX_HOSTS = (() => {
const base = ["stage.breakpilot.com", "breakpilot.com", "localhost"];
const extra = (process.env.PORTAL_APEX_HOSTS ?? "")
.split(",")
.map((h) => h.trim().toLowerCase())
.filter(Boolean);
// Longest-first to keep the suffix-strip loop correct.
return Array.from(new Set([...extra, ...base])).sort(
(a, b) => b.length - a.length,
);
})();
const APEX_SET = new Set(APEX_HOSTS);
export function parseHost(host: string | null | undefined): HostMatch {