I’m passing a custom X-Authorization
header to my API.
In my API, I’m allowing the header like so:
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With, X-Authorization');
I’m checking the headers using print_r(apache_request_headers())
The only reference to X-Authorization
in the response is:
[access-control-request-headers] => x-authorization
I’m using CGI
which I believe strips regular Authorization
headers which is why I am trying a custom one.
2
Answers
you will be able to see the request header under the $_SERVER super global, converted the key to uppercase, with prefix HTTP_ & replacing – to _
for example:
X-foo-bar: baz
will be under:
The following request:
will return:
PHP (test.php):
The following is working for me on Google Chrome:
HTML file data:
Content of 3.php: