From 62b7e9c74d95910038cff51fa4aab747f3822887 Mon Sep 17 00:00:00 2001 From: Aris Ripandi Date: Thu, 5 Sep 2024 17:50:17 +0700 Subject: [PATCH] fix: multi tenancy subdomain --- app/routes/_index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 9b5bba5..f0bdbfe 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -11,11 +11,12 @@ export const loader: LoaderFunction = async ({ request }) => { if (!host) throw new Error('Missing host') const domain = process.env.DOMAIN || 'example.com' + const baseDomain = process.env.NODE_ENV === 'development' ? 'localhost:3000' : domain console.debug('Original host:', host) // Check if it's a subdomain - const isSubdomain = host.endsWith(`.${domain}`) && !host.startsWith('www.') + const isSubdomain = host.endsWith(`.${baseDomain}`) && !host.startsWith('www.') if (!isSubdomain) { console.debug('Not a subdomain, returning default page')