前后台分离,用nginx做请求跨域处理。我用了fetch,来替代ajax。访问正常。但是请求时没带cookie,我就加了credentials: "include"
var myHeaders = new Headers();
fetch(url, {
method: 'GET',
headers: myHeaders,
credentials: "include"
})
这个时候服务端确实拿到了cookie,但是数据返回报错
ERROR :Fetch API cannot load http://localhost:8077/sonny/l... The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…