【问题标题】:CORS : Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.CORS:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。
【发布时间】:2017-10-10 05:54:13
【问题描述】:

当我执行这段代码时,我得到了Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

 axios({
     url: this.state.optImage[i],
     method: 'get',
     withCredentials: true,
     headers: {
     'Accept': 'application/json',
         'Content-Type': 'application/json',
         'Access-Control-Allow-Origin': 'https://*, http://*',
     }
 })

我请求到 s3 服务器,在邮递员中,它运行良好。 我还尝试在“Access-Control-allow-Origin”中添加“*”。 我的代码有什么问题?仅在本地主机中发生吗?我完全不明白。

【问题讨论】:

    标签: cors axios


    【解决方案1】:

    我认为您应该在标头中传递 xsrf-token 或其他内容。仅使用该代码很难知道。尝试添加一些后端代码..

    【讨论】:

      猜你喜欢
      • 2016-02-23
      • 2018-05-06
      • 1970-01-01
      • 2017-11-11
      • 2017-04-09
      • 2017-09-08
      • 2016-12-24
      • 2020-12-07
      相关资源
      最近更新 更多