Skip to content

Commit

Permalink
fix: multi tenancy subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
riipandi committed Sep 5, 2024
1 parent 7faa0b7 commit 62b7e9c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 62b7e9c

Please sign in to comment.