首页 > 解决方案 > 使用子域不会解析到租户

问题描述

因此,我尝试使用租户名称的子域来解决此类问题。在我的例子中,在本地主机中工作,我编辑了我的主机文件以指向一个名为 subdomains 的新租户到 localhost 应用程序。

我能够转到该页面并使用 test.mydomain.com:[port] 正确加载,但它似乎不支持我在 ConfigureServices 中设置的 domaintenantresolver。这是测试子域多租户的完全错误的方法吗?

下面的代码是我在ConfigureServices中调用的函数。我还在我的主机文件中添加了以下几行:127.0.0.1 www.mydomain.com 127.0.0.1 www.meme.mydomain.com

private void ConfigureTenantResolver(ServiceConfigurationContext context, IConfiguration configuration)
    {
      
        Configure<AbpTenantResolveOptions>(options =>
        {
            options.TenantResolvers.Insert(1, new DomainTenantResolveContributor($"{0}.mydomain.com:44327"));
            // OR
            // options.AddDomainTenantResolver($"{0}.mydomain.com:44327");
    
          
            options.TenantResolvers.Add(new QueryStringTenantResolveContributor());
            options.TenantResolvers.Add(new RouteTenantResolveContributor());
            options.TenantResolvers.Add(new HeaderTenantResolveContributor());
            options.TenantResolvers.Add(new CookieTenantResolveContributor());
        });
    }

标签: abp

解决方案


推荐阅读