Fix jwt-token

This commit is contained in:
2025-09-15 10:08:08 +02:00
parent 43dad665ae
commit 94e365c1bb

View File

@@ -90,11 +90,17 @@ 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];
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;
}
}
}
// Method 6: URL path (/tenant2/api/...)
const urlPath = req.path || req.url || '';