fix domains redirections
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user