From b8f0ccba3c7a48c7ee4508b0a23210acb17f2dba Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Thu, 11 Jun 2026 10:47:15 -0400 Subject: [PATCH] fix(frontend): env-driven marketing host detection Exact-match on 'corrosionmgmt.com' meant www. or any staging host silently served the panel instead of the marketing site. Hosts now come from VITE_MARKETING_HOSTS (comma-separated, defaults cover bare + www). Co-Authored-By: Claude Fable 5 --- .env.example | 3 +++ frontend/src/router/index.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 738916e..4309a7b 100644 --- a/.env.example +++ b/.env.example @@ -42,3 +42,6 @@ FRONTEND_URL=http://localhost:5174 # Frontend (Vite — must be prefixed with VITE_) VITE_PANEL_URL=https://panel.corrosionmgmt.com + +# Hostnames that serve the marketing site (comma-separated); all other hosts get the panel +VITE_MARKETING_HOSTS=corrosionmgmt.com,www.corrosionmgmt.com diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index a1ac312..bcc9535 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -14,9 +14,15 @@ declare module 'vue-router' { // --------------------------------------------------------------------------- // Domain detection — runs once at module load +// Env-driven so www./staging hosts route correctly; an exact-match literal +// here once meant any non-canonical marketing host silently got the panel. // --------------------------------------------------------------------------- const hostname = typeof window !== 'undefined' ? window.location.hostname : '' -const isMarketingDomain = hostname === 'corrosionmgmt.com' +const marketingHosts = (import.meta.env.VITE_MARKETING_HOSTS ?? 'corrosionmgmt.com,www.corrosionmgmt.com') + .split(',') + .map((h: string) => h.trim().toLowerCase()) + .filter(Boolean) +const isMarketingDomain = marketingHosts.includes(hostname.toLowerCase()) // --------------------------------------------------------------------------- // Marketing page children — shared between both domain route sets