Do not apply shortname for system tenant generateBaseUrl

Do not remove domain name parts if hostname already is a subdomain
This commit is contained in:
Hendrik Belitz
2026-03-06 10:05:18 +01:00
parent b3c4257ec4
commit 81b7d52e64
+4 -12
View File
@@ -409,18 +409,10 @@ export function generateBaseUrl(requestUrl: URL, tenant: SelectTenant | null): s
return `${protocol}//${hostname}${port}`;
}
// In production, handle tenant subdomains
if (tenant?.shortName) {
const parts = hostname.split(".");
if (parts.length > 2) {
// Complex subdomain - use only the last two parts (domain.tld) and add tenant
const domain = parts.slice(-2).join(".");
return `${protocol}//${tenant.shortName}.${domain}${port}`;
} else {
// Main domain, prepend tenant subdomain
return `${protocol}//${tenant.shortName}.${hostname}${port}`;
}
// In production, handle tenant subdomains.
// Exclude the system tenant when determining if we should use the tenant's shortName for the URL, as the system tenant does not have a shortName and should use the main domain.
if (tenant?.shortName && tenant.id !== "system") {
return `${protocol}//${tenant.shortName}.${hostname}${port}`;
}
// For global admin or no tenant, use main domain