Answer the question
In order to leave comments, you need to log in
Why doesn't XMLHttpRequest.getAllResponseHeaders() show my own custom headers?
Let's say I knock on the server and the server in its response sends me a custom header:
Abra-Kadabra: 543467868998
But I simply don't see this header through XMLHttpRequest.getAllResponseHeaders!
Perhaps the problem is that the server address and the address from which the request is sent are different? If suddenly yes, how would it win? Is it possible to somehow tell on the server side that I allow any headers to be processed?
Answer the question
In order to leave comments, you need to log in
Not all headers are available from scripts in case of different domains / cross-origin, to control this there is a special header Access-Control-Expose-Headers , You need to send 'Access-Control-Expose-Headers' from the server with 'Abra-Kadabra'
Because getAllResponseHeaders() displays the headers of the recipient, which gives you access to the request.
Here's the clarification from the documentation:
XMLHttpRequest.getAllResponseHeaders()
The XMLHttpRequest getAllResponseHeaders() method returns all CRLF-separated response headers as a string, or returns null if no response was received. If a network error occurs, an empty string is returned.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question