Custom header customization for page redirection

I have a web application that allows you to call its server1: 8080 / amcd. There is a parameter in this application that allows the user to automatically register when I pass the header of the user request in the page request. This custom header is called "REMOTE_USER".

My plan is to have another page in another web application, lets call it server2: 8080 / ssoRedirect / test.html this application on server 2 acts like a filter, where I will pass a URL parameter such as server2: 8080 / ssoRedirect /test.html?UserName=user1, this page will take the parameter "user1" and be redirected to page server1: 8080 / amcd, entering the value "user1" in the request page "REMOTE_USER".

any tips on how i can do this?

I looked at a simple java script as shown below, but could not get it to work.

<script>

var url = "http://localhost:8080/index.html?userName=user1"; // or window.location.href for current url
var usernameParam = /userName=([^&]+)/.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/";

</script>

I can do this work when I use the Modify header plugin for chrome and firefox.

Page title image without request

+4
source share
1 answer

- HTTP-, XMLHttpRequest. , , , href. , , :

  • Cookies
  • GET
  • POST
+4

Source: https://habr.com/ru/post/1627533/


All Articles