-
HTTP Error 400. The request hostname is invalid.
-
-
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"
},
1 Answer(s)
-
0
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>