0

I want to retrieve header values from the incoming HTTP Requests, which is coming to my Web App[angular application] and use the retrieved values in the application for other outgoing requests. My angular application is hosted via IIS. I tried using HttpHeaders but its only configurable for outgoing requests.

Please let me know whether its possible or not , if not then what are the work around :)

3
  • Angular runs in the browser. Your Angular code doesn't receive any request. It probably sends some. Check the documentation of the technology you use at server-side (PHP? ASP? ASP.net? something else?) Commented Feb 28, 2018 at 7:03
  • I'm getting the authentication for my application from a third party via the Request header Commented Feb 28, 2018 at 7:09
  • Doesn't change anything: the request is received by your server, not by the browser. Commented Feb 28, 2018 at 7:21

2 Answers 2

0

Unfortunatelly, there doesn't seem to be a way to do that in pure JavaScript.

It looks like the only way around it would be to create an endpoint, that would just return a JSON object with all headers that it received - that way you could just do a request from Angular to said endpoint, and therefore - read all your headers for further reuse.

Whether or not you really need it or want to do that is debatable.

Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible using without any Server side intersepter/endpoint , is their any way via Node JS
Unfortunatelly, no. It looks like there is no interface the browser could query for "what were the headers I sent in this request".
0

First of all, your angular application running in the browser is responsible to send the request, as that app is a client and makes requests and receives responses to those requests.

Secondly, as you mentioned "you are getting authentication for your application from a third party" is unclear.

If you could provide the design of your client-server-authentication in a bit detail, so we could understand what exactly you are trying to achieve. Following is my assumption,

Your application is hosted with windows authentication enabled, and upon your visit to the web app, your browser is negotiating with credential hash.

Now you want to retrieve identity information from that hash at the client side, which is not possible.

But the way your question is put up, the answer is "Not possible and no work around"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.