I have a simple PHP script that I am attempting a cross-domain CORS request:
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
...
Yet I still get the error:
Request header field
X-Requested-Withis not allowed byAccess-Control-Allow-Headers
Anything I’m missing?
Access-Control-Allow-Headersdoes not allow*as accepted value, see the Mozilla Documentation here.Instead of the asterisk, you should send the accepted headers (first
X-Requested-Withas the error says).Update:
*is now accepted isAccess-Control-Allow-Headers.According to MDN Web Docs 2021: