diff --git a/packages/auth/src/tenancy/context.js b/packages/auth/src/tenancy/context.js index b1ef5a5807..01d1fdc604 100644 --- a/packages/auth/src/tenancy/context.js +++ b/packages/auth/src/tenancy/context.js @@ -53,6 +53,11 @@ exports.setTenantId = ( // processed later in the chain tenantId = user.tenantId || header || tenantId + // Set the tenantId from the subdomain + if (!tenantId) { + tenantId = ctx.subdomains && ctx.subdomains[0] + } + if (!tenantId && !allowNoTenant) { ctx.throw(403, "Tenant id not set") }