Vue-resource: 最新版本0.93 跨域 配置 {xhr: {withCredentials: true}} 无法带 cookie

Created on 7 Jul 2016  ·  11Comments  ·  Source: pagekit/vue-resource

Vue.http.post('/user/login', this.form, {xhr: {withCredentials: true}})
无法带上cookie
原 vue-resource v0.7.4 没问题!

Most helpful comment

前端使用vue-resource 拦截器:
Vue.http.interceptors.push((request, next) => {
request.credentials = true
next()
})
后端设置res.header('Access-Control-Allow-Origin', 'XXXX');
注意设置了credentials = true,就不能设置'Access-Control-Allow-Origin', '*',会报错的.

All 11 comments

What?

我也有同样的问题 被迫降低到vue-resource v0.7.4 没问题!

See #327

虽然我用0.9.3设置了credentials: true,但是不能传cookie,换成jquery的话就可以。你们有这种情况吗?详见:https://segmentfault.com/q/1010000005981906

Vue.http.interceptors.push((request, next) => {
request.credentials=true;

楼上+1

前端使用vue-resource 拦截器:
Vue.http.interceptors.push((request, next) => {
request.credentials = true
next()
})
后端设置res.header('Access-Control-Allow-Origin', 'XXXX');
注意设置了credentials = true,就不能设置'Access-Control-Allow-Origin', '*',会报错的.

楼上+1

Vue.http.interceptors.push((request, next) => {
request.credentials=true;

good job!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikeyao picture mikeyao  ·  6Comments

briward picture briward  ·  4Comments

ionutvelicu picture ionutvelicu  ·  5Comments

facesea picture facesea  ·  5Comments

gbhlwm picture gbhlwm  ·  5Comments