'Angular 6 HttpClient response has only some headers
We have a use case in our REST implementation where it returns a special header that we use for pagination and determining the number of pages. I have modified the HttpClient options to observe the entire response. The response I see in chrome has this in its headers:
The special header is Content-Range and I see that in Chrome. When trying to get the Content-Range header in my subscription response, it is null. When debugging it turns out the headers array only has a subset of the actual headers.
I see folks talking about changing a server option to allow. We go through a servlet proxy. In development, all our responses have this:
private void setAccessControlHeaders(HttpServletResponse resp) {
resp.setHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Methods", "*");
resp.setHeader("Access-Control-Allow-Headers", "*");
}
Is there something else I need to do to get access to a custom header?
Solution 1:[1]
I know that you need to add it like below
resp.setHeader("Access-Control-Expose-Headers", "Content-Range");
But can you tell me where this function you have is located?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Abhinav Kumar |