Setting custom request header on a page redirect
<p>I have a web application lets call it server1:8080/amcd this application has a setting in it that allows a user to be auto logged in when i pass in a custom request header in the page request. This custom header is called "REMOTE_USER". </p>

<p>My plan is to have another page on another web application, lets call it server2:8080/ssoRedirect/test.html this app on server 2 is acting like a filter where i will pass in a URL parameter such as server2:8080/ssoRedirect/test.html?UserName=user1 this page will take the "user1" parameter and redirect to server1:8080/amcd page while injecting the "user1" value in the "REMOTE_USER" page request.</p>

<p>Any advice in how to I might accomplish this? </p>

<p>I was looking at some simple javascript like below but could not get it to work. </p>

<pre><code>&lt;script&gt;

var url = "http://localhost:8080/index.html?userName=user1"; // or window.location.href for current url
var usernameParam = /userName=([^&amp;]+)/.exec(url)[1]; 
var result = usernameParam ? usernameParam : 'myDefaultValue';

 function customHeader(remoteinput, userinput) {
    var client = new XMLHttpRequest();
    client.open("POST", "/log");
    client.setRequestHeader(remoteinput, userinput);

}
    window.location.href = "http://ephesoft.eastus2.cloudapp.azure.com:8080/dcma/";

&lt;/script&gt;
</code></pre>

<p>I am able to make this work when I use the Modify header plugin for chrome and firefox. </p>

<p><a href="https://i.stack.imgur.com/qhGXR.png" rel="noreferrer">Image of not request page header</a></p>