Fix jwt-token
This commit is contained in:
@@ -53,16 +53,8 @@ class MultiTenantAuth {
|
||||
* Can be from subdomain, header, or JWT
|
||||
*/
|
||||
async determineTenant(req) {
|
||||
console.log('🚀 DETERMINE TENANT FUNCTION START');
|
||||
console.log('===== DETERMINE TENANT CALLED =====');
|
||||
console.log('🏢 req.user:', req.user);
|
||||
console.log('🏢 req.headers.host:', req.headers?.host);
|
||||
console.log('🏢 req.url:', req.url);
|
||||
console.log('🏢 req.path:', req.path);
|
||||
|
||||
// Method 1: From authenticated user (highest priority)
|
||||
if (req.user && req.user.tenantId) {
|
||||
console.log('🏢 Tenant from req.user.tenantId:', req.user.tenantId);
|
||||
return req.user.tenantId;
|
||||
}
|
||||
|
||||
@@ -87,11 +79,9 @@ class MultiTenantAuth {
|
||||
|
||||
// Method 4: x-forwarded-host header (for proxied requests)
|
||||
const forwardedHost = req.headers['x-forwarded-host'];
|
||||
console.log('🏢 x-forwarded-host header:', forwardedHost);
|
||||
if (forwardedHost) {
|
||||
const subdomain = forwardedHost.split('.')[0];
|
||||
if (subdomain && subdomain !== 'www' && subdomain !== 'api' && !subdomain.includes(':')) {
|
||||
console.log('🏢 Tenant from x-forwarded-host:', subdomain);
|
||||
return subdomain;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user