请求标头字段X-Requested [英] Request header field X-Requested

查看:113
本文介绍了请求标头字段X-Requested的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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无法加载"FILENAME".

"XMLHttpRequest cannot load "FILENAME".

在飞行前响应中,Access-Control-Allow-Headers不允许使用请求标头字段X-Requested-With."

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

推荐答案

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

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
    }
]

请参见相关文档,其中说:

如果这是预检请求,请检查预检请求是否包含一个或多个Access-Control-Request-Header.如果是这样,则确保匹配的CORS配置条目包括每个请求的标头的<ResponseHeader>条目. Access-Control-Request-Header中命名的所有标头必须都处于CORS配置中,才能使预检请求成功,并且在响应中包括CORS标头.

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.

这篇关于请求标头字段X-Requested的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆