遇到一个跨域携带cookie的问题,vue项目使用axios发送跨域请求,并且前端往cookie里塞了些东西,node后端取不到这个cookie
axios已设置withCredentials=true
;
node后端已设置
res.header('Access-Control-Allow-Origin', 'http://localhost:8080');
res.header('Access-Control-Allow-Credentials', 'true')
axios已设置withCredentials=true
;
node后端已设置
res.header('Access-Control-Allow-Origin', 'http://localhost:8080');
res.header('Access-Control-Allow-Credentials', 'true')
1.客户端withCredentials=false
不发送cookie
2.客户端withCredentials=true
如果跨域且后端不允许跨域字段包含Cookie是,不发送cookie
综上withCredentials=true
&& (不跨域
||后端允许跨域
&&后端允许跨域字段包含cookie
)
10 回答11.6k 阅读
2 回答3.1k 阅读✓ 已解决
3 回答2.7k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
3 回答790 阅读✓ 已解决
你总结的很对,浏览器的安全策略就是如此,如果要跨域动态传参的话没法放到cookie里去传