跨域 ajax 请求中的预检 header 未解决授权 header

Authorization header not solved from preflight header in cross domain ajax request

我想从 https://A/ to https://B/jquery ajax 访问一个跨域。

我的请求 header 看起来像:

Access-Control-Request-Headers: authorization
Access-Control-Request-Method: GET
Origin: https://A
Referer: https://A/test/index.html

实际上在服务器端设置了所有必要的 header:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,C$
Access-Control-Allow-Methods: GET,POST,OPTIONS,DELETE,PUT,PROPFIND,PROPPATCH,NOTIMPLEMENTED,OPTIONS,UNLOCK,MKCOL,COPY,LOCK,MOVE,HEAD
Access-Control-Allow-Origin: https://A
Access-Control-Max-Age: 1728000

但是我的 Google Chrome 仍然只发送上面的预检 headers,而不是真正的 headers,所以我一直收到 401 错误。我错过了什么吗?

更新: Chrome 给出以下错误消息:

Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

好的,我有一个解决方法。我在我请求的文档中添加了以下 PHP-Code。

if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
    http_response_code(200);
    exit;
}

但我仍然愿意寻求更好的解决方案。