Base solution for your next web application
Open Closed

WebSiteRootAddress inconsistent usage #2773


User avatar
0
DennisAhlin created

Hi! When using domain resolved tenants, the website root address setting have incosistent behaviour.

If I have: server at: <a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a> angular ui at: <a class="postlink" href="http://tenant.mydomain.com">http://tenant.mydomain.com</a>

When server is trying to figure out which tenant is enabled, it uses the host address (<a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a>) here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/850fbe6d851ccdb906c05f77d88b4003de6e1d5c/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs#L41">https://github.com/aspnetboilerplate/as ... tor.cs#L41</a> and compares it to the _multiTenancyConfiguration.DomainFormat, which is App:WebSiteRootAddress setting, so App:WebSiteRootAddress needs to be set to the format of the host (http://{TENANCY_NAME}.api.mydomain.com).

However, when an activation mail is sent when creating a tenant here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/1ead91936c496521e171f3fdf70d129bee021ff2/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Url/AppUrlServiceBase.cs#L34">https://github.com/aspnetzero/aspnet-ze ... ase.cs#L34</a> , the activation link uses WebUrlService.GetSiteRootAddress, which is also the App:WebSiteRootAddress setting. This leads to the activation link becomes <a class="postlink" href="http://tenant.api.mydomain.com/route">http://tenant.api.mydomain.com/route</a>, which is wrong. It should be <a class="postlink" href="http://tenant.mydomain.com/route">http://tenant.mydomain.com/route</a>, otherwise the link doesn't work.

Maybe separate WebSiteRootAddress into two settings? And also name them more clearly (ClientRootAddressFormat/HostRootAddressFormat)?

As a side note, when having the setting without the trailing slash as workaround for previous tenant domain resolver bug, the activation link misses slash between root and relative path (<a class="postlink" href="http://tenant.api.mydomain.comroute">http://tenant.api.mydomain.comroute</a>). I think the url in AppUrlService base should be concatenated in some way that is not sensitive to having a trailing slash or not.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thank you for your detailed explanation. This seems like an important bug, we will fix it as soon as possible. Please follow <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/108">https://github.com/aspnetzero/aspnet-ze ... issues/108</a>.