带有Ajax请求的CORS标头

I tried since 5 days to configure correctly CORS to solve the error :

So I tried to add :

header('Access-Control-Allow-Origin: *'); 

On my webservice (on the same server but different domain name), I got this error :

Request header field Authorization is not allowed by Access-Control-Allow-Headers

Then I tried to add :

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
 </IfModule>

To a .htaccess file that I created. But still doesn't work.

Any idea ? Thanks a lot in advance.

You must include an Access-Control-Allow-Headers header in your response with the proper acceptable header names, just as the error message suggests. It sounds like you do not know how to properly handle CORS requests. Please read this document on MDN, which explains how to handle CORS requests. This will answer all of your questions.