Files
dezky/apps/website/middleware/coming-soon.global.ts
T
Ronni Baslund 04191193c2 feat(website): gated coming-soon holding page with email signup
Add a standalone bilingual /coming-soon page (branded, dark, email signup
via mailto:info@dezky.eu, fires a waitlist-signup Umami event, noindex) plus
a global middleware that redirects every route to the locale-correct holding
page while NUXT_PUBLIC_COMING_SOON=true.

- Env-gated (default off, so dev and the live site are unaffected); flip the
  env in Coolify to show/hide the holding page with no code change.
- Preview the real site behind the gate via ?preview=<previewToken>
  (NUXT_PUBLIC_PREVIEW_TOKEN), which sets a 7-day cookie.
- Locale-preserving redirects (/da/* -> /da/coming-soon), no loops.
2026-06-06 21:51:26 +02:00

26 lines
1.0 KiB
TypeScript

// Holding-page gate. While NUXT_PUBLIC_COMING_SOON=true, every route is
// redirected to the locale-appropriate /coming-soon page so the unfinished
// site stays hidden. Flip the env to false (in Coolify) to launch — no code
// change. The team can preview the real site via ?preview=<token>, which sets
// a short-lived cookie so subsequent navigation stays unlocked.
export default defineNuxtRouteMiddleware((to) => {
const config = useRuntimeConfig()
if (!config.public.comingSoon) return
// Never redirect the holding page itself (avoids a loop).
if (to.path === '/coming-soon' || to.path === '/da/coming-soon') return
const token = config.public.previewToken as string
const bypass = useCookie<string | null>('dz_preview', {
maxAge: 60 * 60 * 24 * 7, sameSite: 'lax', path: '/',
})
if (token && to.query.preview === token) {
bypass.value = '1'
return
}
if (bypass.value === '1') return
const isDa = to.path === '/da' || to.path.startsWith('/da/')
return navigateTo(isDa ? '/da/coming-soon' : '/coming-soon')
})