跨域问题解决

新手上路,请多包涵

XMLHttpRequest cannot load http://up.qiniu.com/. Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

阅读 10.5k
1 个回答

像这样的一个跨域ajax请求

$.ajax({
    type: "POST",
    url: 'http://up.qiniu.com',
    data: {},
    xhrFields: {
        withCredentials: true
    },
    crossDomain: true,
    dataType: 'json',
    success: successHandler
});

其中设置withCredentials为true,需要response header中的'Access-Control-Allow-Origin'为一个确定的域名,而不能使用'*'这样的通配符。
去掉withCredentials,或者设置为'false'就可以了。