Open Closed

Unable to configure sub-domain in the Application #6606


User avatar
0
pvala created
  • ABP Framework version: v7.3.2
  • UI Type: Angular
  • Database System: EF Core (MySQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I want to implement sub-domain functionality in my application. I followed the following document to do so, but I wasn't able to configure it. https://docs.abp.io/en/abp/latest/Multi-Tenancy

I added the below code in the PreConfigureServices method in my Auth Server Module.cs file :

    PreConfigure<AbpOpenIddictWildcardDomainOptions>(options =>
    {
        options.EnableWildcardDomainSupport = true;
        options.WildcardDomainsFormat.Add("https://{0}.localhost");
    });

And added the below code in the ConfigureServices method in my Auth Server Module.cs file :

    Configure<AbpTenantResolveOptions>(options =>
    {
        options.AddDomainTenantResolver("{0}.localhost");
    });
    

I also updated the appsettings.json file which will accept all the sub-domains as of now (used * wildcard). I have added a test sub-domain name in my machine (test.localhost)

The angular application is working on http://test.localhost:4200/ But the Auth Server application is not running on https://test.localhost:44322/Account/Login

It's getting the following error

However, its working fine on https://localhost:44322/Account/Login

Can you tell me what can be the issue here?


11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you check this? https://community.abp.io/videos/extend-tenant-management-and-add-custom-host-to-your-abp-app-lwmi9lr5

  • User Avatar
    0
    pvala created

    I am able to configure the sub-domain thing in my application. How can I separate the auth server as well on the basis of the the sub-domain? test.localhost:4200 should have it's own test.localhost:44322 auth server. How can we achieve this?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We have an example: https://github.com/abpframework/abp-samples/blob/master/DomainTenantResolver/OpenIddict/NG/angular/src/environments/environment.ts#L13-L22

  • User Avatar
    0
    pvala created

    When I am trying to login from the test.localhost auth server, the user is not getting stored in the currentUser element of the json response that we get on this api call

    https://localhost:44325/api/abp/application-configuration?includeLocalizationResources=false

    However, when I check the CurrentUser in the Auth Server application, it shows me the correct user, but when running redirected to the angular application the currentUser shows empty. What should I do?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share some screenshots and error logs? thanks.

  • User Avatar
    0
    pvala created

    Sure. Let me walk you through how my app is running.

    This is my default auth server :

    This is the auth server for test tenant :

    This is default angular app :

    This is the angular app for test tenant :

    When I try to login from default auth server, it gets redirected to the default angular app and when I check the inspect, the currentUser is there, which is fine and it lets me login into the application.

    But when I try to login from test auth server, it gets redirected to the test.localhost angular app and when I check the inspect, the currentUser is empty because of which, it doesn't let the user go inside the angular app as a logged in user. But when I check in the Auth Server, the user is there in the CurrentUser Interface instance.

    Here in the below code, in the CurrentUser variable, I am getting the details of the user, but in angular it shows empty.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    have you tried this? https://docs.abp.io/en/abp/latest/Multi-Tenancy#domain-subdomain-tenant-resolver

  • User Avatar
    0
    pvala created

    Okay, this worked. Now, how will my application differentiate between different subdomains? For example, if the name of the subdomain is test, then how will ABP know which tenant it has to map it with? Also, if my tenant name has a space ("Test Tenant" for instance), what will be the subdomain name?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    ABP does not support parsing tenant names with spaces, you can use id for this case. for example:

    https://e2cfa63d-21f5-44e9-9866-6e19991739e5.localhost.com

  • User Avatar
    0
    pvala created

    And in case of no space, does the case sensitivity affect the tenant name?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi, no affect

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35