title: How to get the HTTP request headers from initial page request in ReactJS
body: <p><em>I have read a lot of answers but couldn't able to find anything satisfactory. The user roles in the application depend on the information I will receive in headers.
  I have already tried this:</em></p>
  
  <pre><code>var req = new XMLHttpRequest(); req.open('GET', document.location,false); req.send(null); 
  var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
  </code></pre>
  
  <p><em>But i think i generates a new request and by then the URL changes so the headers are not the same.</em>
  <em>If there is any other option to get the headers please guide me with the same</em></p>
  
  <p>Edit 1 (This will clarify the question a little more):</p>
  
  <ul>
  <li>The user would click on my application(Let's say application1) link via another application (Let's say application2).</li>
  <li>Then the applicaion2 will send the HTTP/HTTPs headers in requests forwarded by the reverse proxy, which will contain user role and some more information.</li>
  <li>In the headers I will receive user roles.</li>
  <li>Depending on the role the kind of access would be determined and given to user </li>
  </ul>