feat(portal): allow PORTAL_APEX_HOSTS env to extend APEX_HOSTS #15
Reference in New Issue
Block a user
Delete Branch "feat/env-driven-apex-hosts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The portal's apex list was hardcoded to
[stage.breakpilot.com, breakpilot.com, localhost]. Deploying it atportal-dev.meghsakha.com(or any other hostname while the canonical domain isn't registered yet) hits the apex fallback for every subdomain because the parser doesn't recognize the suffix.What
Add a comma-separated
PORTAL_APEX_HOSTSenv var that prepends extras to the default list. Sorted longest-first so the suffix-strip loop stays correct.Now
acme.portal-dev.meghsakha.comparses to{ kind: "tenant", slug: "acme" }.The defaults (breakpilot.com, stage.breakpilot.com, localhost) still work without setting the env.
Test plan
pnpm test— full suite passes with 100% coverage on src/lib (unchanged from before; the IIFE is exercised by existing parseHost tests)PORTAL_APEX_HOSTS=portal-dev.meghsakha.com, the portal recognizes<slug>.portal-dev.meghsakha.comsubdomains as tenants🤖 Generated with Claude Code