fix domains redirections

This commit is contained in:
root
2026-05-15 12:44:12 -04:00
parent 0edd90732e
commit 942c0b282a
4 changed files with 17 additions and 10 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
const PRODUCTION_DOMAIN = 'rentaldrivego.com'
const PRODUCTION_DOMAIN = process.env.NEXT_PUBLIC_PUBLIC_SITE_DOMAIN ?? 'rentaldrivego.ma'
const DEFAULT_SLUG = process.env.NEXT_PUBLIC_COMPANY_SLUG ?? 'demo'
/**
* Resolve the company slug from the request host.
*
* Production: {slug}.rentaldrivego.com → slug
* Production: {slug}.<public-site-domain> → slug
* Development: localhost / 127.0.0.1 → DEFAULT_SLUG (env var fallback)
* Staging/preview URLs that don't match the production domain also fall back.
*/
@@ -17,7 +17,7 @@ function resolveSlug(host: string | null): string {
// Strip port number if present
const hostname = host.split(':')[0]
// Production subdomain: slug.rentaldrivego.com
// Production subdomain: slug.<public-site-domain>
if (hostname.endsWith(`.${PRODUCTION_DOMAIN}`)) {
const subdomain = hostname.slice(0, hostname.length - PRODUCTION_DOMAIN.length - 1)
// Ignore www / bare domain