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 :)

Akhil RJ
  • 312
  • 1
  • 4
  • 19
  • 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?) – JB Nizet Feb 28 '18 at 07:03
  • I'm getting the authentication for my application from a third party via the Request header – Akhil RJ Feb 28 '18 at 07:09
  • Doesn't change anything: the request is received by your server, not by the browser. – JB Nizet Feb 28 '18 at 07:21

2 Answers2

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.

samu
  • 2,870
  • 16
  • 28
  • Is it possible using without any Server side intersepter/endpoint , is their any way via Node JS – Akhil RJ Mar 06 '18 at 16:00
  • Unfortunatelly, no. It looks like there is no interface the browser could query for "what were the headers I sent in this request". – samu Mar 07 '18 at 10:10
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"

rAhulD
  • 59
  • 8