1

I have a simple post request with axios:

axios.post('my endpoint', values).then(res => console.log(res.headers));

axios is listing those values as headers:

cache-control: "max-age=0, private, must-revalidate"
content-length: "13757"
content-type: "application/xml; charset=utf-8"

but when I check the network tab in chrome, I can see those values under response headers:

access-control-allow-origin: http://localhost:8080
access-control-expose-headers: Total,Total-Pages
cache-control: max-age=0, private, must-revalidate
content-length: 13757
content-type: application/xml; charset=utf-8
date: Thu, 02 Sep 2021 19:37:42 GMT
x-envoy-upstream-service-time: 385
x-request-id: FqEYfGCtbcHGzzwASr4C

I need to access the x-request-id header, but there is no way to get this with axios or fetch.

I saw some messages about the header being blocked by cors, but I have X-Request-Id in my access-control-allow-headers

Someone has any idea how to get this header with axios?

jonathanrz
  • 4,206
  • 6
  • 35
  • 58

1 Answers1

2

I think you have to specify this on the server so that axios has access to the specific headers you require.

https://stackoverflow.com/a/37931084/8818020