首页 > react+redux 调服务端接口中,报Fetch API cannot load 怎么解决

react+redux 调服务端接口中,报Fetch API cannot load 怎么解决

method: 'GET',
        headers: {
            'Accept': 'application/json',
          form-urlencoded
            'Content-Type': 'application/json;charset=utf-8'
        },
        mode : 'cors'  //实现跨域
        // headers: form.getHeaders()

我们使用了mode : 'cors' //实现跨域的方法,但是还是不能跨域,后台的token取不到,所有接口中的信息都调不到,全部报错信息为:

Fetch API cannot load http://devapi.jiaj1.com.cn:8080/masterdatas/geo/provinces. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8080' is therefore not allowed access.
undefined:1 Uncaught (in promise) TypeError: Failed to fetch(…)

抱大腿了,请问该怎么解决?

引用文字


你用浏览器开发工具抓一下请求,应该已经请求成功,但是可能服务器没有返回合适的Access-Control-Allow-Origin头。

【热门文章】
【热门文章】