Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

select tenant based on subdomain in multi-tenant setup #9464


User avatar
0
dev_frontrush created

Hello,

We are trying to setup tenant selection by subdomain as mentioned in documenation https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Overview-Angular#multi-tenancy .

appconfig.json in angular looks like - "remoteServiceBaseUrl": "https://api-dev.domain.org", "appBaseUrl": "https://{TENANCY_NAME}.dev.domain.org",

And in api project appsettings.json is "ServerRootAddress": "https://api-dev.domain.org", "ClientRootAddress": "https://{TENANCY_NAME}.dev.domain.org", "CorsOrigins": "https://.dev.domain.org,https://.domain.org",

Api and angular are setup as separate applications in iis, and I have verified that the wildcard binding is working as expected. After setting this up, When I go to tenant specific url I dont see any cookie getting set with tenantid. I have checked AppPreBootstrap.ts file in angular, and I dont see any code that is setting cookie when using subdomain for tenant selection.

Please advise.

Thank you,


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    Why the ServerRootAddress and remoteServiceBaseUrl don't have the {TENANCY_NAME}?

    The API application will also get tenant by the subdomain.

  • User Avatar
    0
    dev_frontrush created

    Thank you responding. I got the angular app to select tenant by updating remoteserviceBaseUrl and ServerRootAddress to have {TENANCY_NAME}.

    How do I go to tenant login page now, I would also like to have the ability to be able to set tenant by coming to a host url.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dev_frontrush

    You can go to tenant login page https://tenant1.dev.domain.org. If user is not logged in, user will be redirected to login page. If you visit host page (https://dev.domain.org), by default, AspNet Zero doesn't show tenant selection box. If you want it to act like that, you need to change the source code of login page.

  • User Avatar
    0
    dev_frontrush created

    thank you! all working now.