question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to see extra headers from response

See original GitHub issue

When trying to access response headers, the only header i can see is Content-Type although server replies with extra ones.

I’m able to get whole response with no issue using http resource:

this.serverRequest().then(
    response => {
        console.log(response.headers)
    },
    error => {}
)

Consider next server response:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Authorization, Content-Type
Access-Control-Allow-Methods:OPTIONS, POST
Access-Control-Allow-Origin:http://localhost:4000
Connection:keep-alive
Content-Length:112
Content-Type:application/json
Date:Sun, 26 Nov 2017 21:50:49 GMT
Server:Cowboy
Via:1.1 vegur
X-Password-Token: 1234567890abcdef
X-Server-Time:1511733049

What is Expected?

Expected to see at least X-Password-Token and X-Server in console log (ideally, one would see all headers returned by server)

What is actually happening?

Seeing only content-type in headers mapping console log

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
stgogmcommented, Dec 19, 2017

Well, it is a browser issue indeed. Browsers need an access-control-expose-headers header to make them avilable when using the fetch API while performing a CORS request (more here).

In short: you must set your server response with the comma-separated list of headers list you want to expose to your response.

Example: access-control-expose-headers: x-password-token,x-server-time

I strongly recommend you to use all-lower-case as I’ve had some trouble while using others.

3reactions
edamiancommented, Mar 2, 2018

@stgogm you’re right, it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to access custom response header in frontend ...
I can see the header in the chrome dev-tools console, but I cannot get access to the header through axios. chrome dev tools...
Read more >
How to troubleshoot the error "Failed to process response ...
In almost every event, this error is caused by a connection failure. The error is correct, the service did not receive any response...
Read more >
Access-Control-Expose-Headers - HTTP - MDN Web Docs
The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts ...
Read more >
Adding HTTP headers to CloudFront responses
A Cache-Control header to control browser caching. · An Access-Control-Allow-Origin header to enable cross-origin resource sharing (CORS). · A set of common ...
Read more >
HTTP header manipulation - Envoy Proxy
Custom request/response headers can be added to a request/response at the weighted cluster, route, virtual host, and/or global route configuration level. See ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found