我想要跨域带上cookies
,为什么withCredentials: true
不起作用?
我尝试过axios.defaults.withCredentials = true
可以起作用。
但是为什么单独配置,没有作用?
axios.post('http://101.132.138.141:8888/service/pageUsers', objectToForm({ 'currentPage': '1', 'pageSize': '10', 'token': '7e987daa-6c84-46d2-be26-f345dfaed8a7', }), { // 单独配置 withCredentials: true }) .then(function(res) { console.log(res.data); }) .catch(function(err) { console.error(err); });
已拦截跨源请求:同源策略禁止读取位于 http://101.132.138.141:8888/service/pageUsers 的远程资源。(原因:CORS 头缺少 'Access-Control-Allow-Origin')。
后端已经设置了CORS
头,但是因为没有附带上cookies
,所以被拦截器拦截了。
潇潇雨雨
相关分类