mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-04 18:06:08 +01:00
Improve domain mapping constraint
- Fix potential double assignment to appId, leading to an [exception](https://pastebin.com/j8dhtcTE) - Add port to redirect, which makes it work in dev env
This commit is contained in:
parent
d14ce2a37f
commit
3c344331af
1 changed files with 9 additions and 6 deletions
|
@ -38,8 +38,9 @@ namespace BTCPayServer.Filters
|
|||
if (matchedDomainMapping != null)
|
||||
{
|
||||
var req = context.RouteContext.HttpContext.Request;
|
||||
var url = new UriBuilder(req.Scheme, matchedDomainMapping.Domain).ToString();
|
||||
context.RouteContext.HttpContext.Response.Redirect(url);
|
||||
var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain);
|
||||
if (req.Host.Port.HasValue) uri.Port = req.Host.Port.Value;
|
||||
context.RouteContext.HttpContext.Response.Redirect(uri.ToString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -55,15 +56,17 @@ namespace BTCPayServer.Filters
|
|||
return false;
|
||||
if (appType != matchedDomainMapping.AppType)
|
||||
return false;
|
||||
context.RouteContext.RouteData.Values.Add("appId", matchedDomainMapping.AppId);
|
||||
return true;
|
||||
if (!hasAppId)
|
||||
{
|
||||
context.RouteContext.RouteData.Values.Add("appId", matchedDomainMapping.AppId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AppType == policies.RootAppType)
|
||||
if (AppType == policies.RootAppType && !hasAppId && !string.IsNullOrEmpty(policies.RootAppId))
|
||||
{
|
||||
context.RouteContext.RouteData.Values.Add("appId", policies.RootAppId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue