Open Closed

Bad Request - Invalid Hostname - Multitenancy Subdomain #9078


User avatar
0
tedAspwv created
  • HTTP Error 400. The request hostname is invalid.

  • Screenshot 2025-04-02 105653.png

  • image.png

I am trying to add Multitenancy to a MVC Tiered solution. After adding a tenant into the application, I cannot hit the subdomain on the auth site. I get a "The request hostname is invalid" response. Hitting the public site with the subdomain works without issue. It is throwing no errors into the log file and in the browser it is only returning the 400 error. This is happening when running the site through Visual Studio and when deploying to local IIS.

I've added the following code to the module, in the PreConfigureServices:
PreConfigure<AbpOpenIddictWildcardDomainOptions>(options =>
{
options.EnableWildcardDomainSupport = true;
options.WildcardDomainsFormat.Add("https://{0}." + configuration["App:SelfUrl"]!.Replace("https://", ""));
options.WildcardDomainsFormat.Add("https://{0}." + configuration["App:PublicSiteUrl"]!.Replace("https://", "") + "/signin-oidc");
options.WildcardDomainsFormat.Add("https://{0}." + configuration["App:PublicSiteUrl"]!.Replace("https://", "") + "/signout-callback-oidc");
});

In the ConfigureServices:
Configure<AbpTenantResolveOptions>(options =>
{
string selfUrl = configuration["App:SelfUrl"]!;

// Step 1: Remove "https://"
selfUrl = selfUrl.Replace("https://", "");

options.AddDomainTenantResolver("{0}." + selfUrl);

});

Configure<OpenIddictServerOptions>(options =>
{
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator;
options.TokenValidationParameters.ValidIssuers = new[]
{
configuration["AuthServer:Authority"]! + "/",
"https://{0}." + configuration["AuthServer:Authority"]!.Replace("https://","") + "/"
};
});

My appsettings.json is:
"App": {
"SelfUrl": "https://staxlabs.dev:44383",
"DisablePII": false,
"HealthCheckUrl": "/health-status",
"PublicSiteUrl": "https://staxlabs.dev:44367"

},
Screenshot 2025-04-02 111004.png


1 Answer(s)
  • User Avatar
    0
    tedAspwv created

    I have it working. I had to update the applicationhost.config to use the bindings.
    <bindings>
    <binding protocol="https" bindingInformation=":44383:localhost" />
    <binding protocol="https" bindingInformation="
    :44383:nationaltravel.staxlabs.dev" />
    <binding protocol="http" bindingInformation=":8130:localhost" />
    <binding protocol="http" bindingInformation="
    :8130:nationaltravel.staxlabs.dev" />
    </bindings>

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 25, 2025, 11:10