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