您的位置:首页 > Web前端 > Vue.js

使用vue时,发送请求不带cookie

2017-04-11 08:31 64 查看

第一次使用VUE进行开发,在获取图片验证码与服务器进行比对时,提示验证码错误,最后发现请求时未携带cookie,导致SESSIONID改变致使校验失败.

解决办法

Vue.http.options.emulateJSON = true;
Vue.http.options.xhr = { withCredentials: true }

//在拦截其中添加此属性即可
Vue.http.interceptors.push((request, next) => {
request.credentials = true
next()
})

//axios设置

axios.defaults.withCredentials=
true

转载于:https://www.cnblogs.com/oldcownotGiveup/p/6691870.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: