Fix jwt-token
This commit is contained in:
@@ -90,9 +90,15 @@ class MultiTenantAuth {
|
||||
// Method 5: Subdomain (tenant.yourapp.com)
|
||||
const hostname = req.hostname || req.headers.host || '';
|
||||
if (hostname && !hostname.startsWith('localhost')) {
|
||||
const subdomain = hostname.split('.')[0];
|
||||
if (subdomain && subdomain !== 'www' && subdomain !== 'api' && !subdomain.includes(':')) {
|
||||
return subdomain;
|
||||
const hostParts = hostname.split('.');
|
||||
// Only treat as subdomain if there are at least 2 parts (subdomain.domain.com)
|
||||
// and the first part is not a common root domain
|
||||
if (hostParts.length >= 3) {
|
||||
const subdomain = hostParts[0];
|
||||
if (subdomain && subdomain !== 'www' && subdomain !== 'api' && !subdomain.includes(':')) {
|
||||
console.log('🏢 Tenant from subdomain:', subdomain);
|
||||
return subdomain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user