没法携带Cookie至后端
我用的是vuecli3版本,发post请求,用了网上的axios.defaults.withCredentials=true依然无济于事
登陆时,后台能收到数据,但是rightCode=null(就是存在我本地cookie里的验证码),导致一直返回验证码错误。
相关代码
main.js中
import axios from "axios";
import VueAxios from "vue-axios"
axios.defaults.withCredentials=true;
Vue.use(VueAxios,axios)
login.vue组件中
submit(){
this.axios.post('/user/login',
{
account: this.account,
password: this.password,
checkCode: this.checkCode
},{
headers: {"Content-Type":"application/json;charset=utf-8"},
// withCredentials:true
}).then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
}
摆脱各位伸出援手,我是真的顶不住了。不知道我这样描述是否清楚,不清楚可以继续问我,真心求解,两天了困扰我
F12检查下,确定时COOKIE发不过去?这个问题我之前也遇到过,也很有可能是后端的问题。