Fix jwt-token
This commit is contained in:
@@ -90,11 +90,17 @@ class MultiTenantAuth {
|
|||||||
// Method 5: Subdomain (tenant.yourapp.com)
|
// Method 5: Subdomain (tenant.yourapp.com)
|
||||||
const hostname = req.hostname || req.headers.host || '';
|
const hostname = req.hostname || req.headers.host || '';
|
||||||
if (hostname && !hostname.startsWith('localhost')) {
|
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(':')) {
|
if (subdomain && subdomain !== 'www' && subdomain !== 'api' && !subdomain.includes(':')) {
|
||||||
|
console.log('🏢 Tenant from subdomain:', subdomain);
|
||||||
return subdomain;
|
return subdomain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Method 6: URL path (/tenant2/api/...)
|
// Method 6: URL path (/tenant2/api/...)
|
||||||
const urlPath = req.path || req.url || '';
|
const urlPath = req.path || req.url || '';
|
||||||
|
|||||||
Reference in New Issue
Block a user