请求 header 字段 X-Requested

Request header field X-Requested

我正在尝试访问 google 云存储上存储桶中的文件。我已经为存储桶设置了 CORS 配置。但是当我通过 https:// 发出请求时出现此错误。它适用于通过 http://.

发出的请求

"XMLHttpRequest cannot load "文件名”。

预检响应中的 Access-Control-Allow-Headers 不允许请求 header 字段 X-Requested-With。“

您必须在配置中 responseHeader 成员的值中包含 X-Requested-With

[
    {
      "origin": ["http://example.appspot.com"],
      "responseHeader": ["X-Requested-With"],
      "method": ["GET", "POST"],
      "maxAgeSeconds": 3600
    }
]

the relevant docs,其中说:

If this is a preflight request, check if the preflight request includes one or more Access-Control-Request-Header. If so, then ensure that the matching CORS configuration entry includes a <ResponseHeader> entry for each requested header. All headers named in the Access-Control-Request-Header must be in the CORS configuration for the preflight request to succeed and include CORS headers in the response.