Request header field X-Requested

China☆狼群 提交于 2019-12-12 16:27:08

问题


I am trying to access a file in a bucket on google cloud storage. I have set the CORS configuration for the bucket. But I am getting this error when I make a request across https://. It works fine for requests made across http://.

"XMLHttpRequest cannot load "FILENAME".

Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers in preflight response."


回答1:


You must include X-Requested-With in the value of the responseHeader member in your config:

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

See the relevant docs, which say:

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.



来源:https://stackoverflow.com/questions/43420078/request-header-field-x-requested

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!