Skip to content

Commit

Permalink
Merge pull request #3971 from cisagov/fix-pipeline-config
Browse files Browse the repository at this point in the history
Fix Pipeline Config Rewrite
  • Loading branch information
randywoods authored Jun 20, 2024
2 parents 54cb571 + 1267e59 commit de7cdf6
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ Newtonsoft.Json.Linq.JObject processUpdatedJson(HttpRequest context)
document.Add("rewrittenByRedirect", "true");

JToken element = document["app"];

element["url"] = context.Host.Host;
element["host"] = context.Host.Host;
if (String.IsNullOrWhiteSpace(context.Headers["X-Forwarded-Proto"]))
{
element["protocol"] = context.Scheme;
Expand All @@ -160,7 +159,24 @@ Newtonsoft.Json.Linq.JObject processUpdatedJson(HttpRequest context)
}

element = document["api"];
element["url"] = context.Host.Host;
element["host"] = context.Host.Host;
if (String.IsNullOrWhiteSpace(context.Headers["X-Forwarded-Proto"]))
{
element["protocol"] = context.Scheme;
string port = "443";
if ((context.Host.Port == 80) || (context.Host.Port == 443))
port = "";
else
port = (context.Host.Port == null) ? "" : context.Host.Port.ToString();
element["port"] = port;
}
else
{
element["protocol"] = context.Headers["X-Forwarded-Proto"].ToString();
element["port"] = context.Headers["X-Forwarded-Port"].ToString();
}

element = document["library"];
if (String.IsNullOrWhiteSpace(context.Headers["X-Forwarded-Proto"]))
{
element["protocol"] = context.Scheme;
Expand Down

0 comments on commit de7cdf6

Please sign in to comment.