Reputation: 125
In main.js, I put
axios.defaults.withCredentials = true;
It should work, but by this way the cookies are not sent to the back end.
Here the request header
If in specific request I add {withCredentials: true}, it's work fine
However, I put an interceptor for all request, to check the options sent,
Do you have an idea not to put in each request this option?
Thank you in advance
Upvotes: 2
Views: 14802
Reputation: 10715
Axios also provide interceptors. You can configure it like this:
axios.interceptors.request.use(
function(config) {
// Do something before request is sent
config.withCredentials = true;
return config;
},
function(error) {
// Do something with request error
return Promise.reject(error);
}
);
Upvotes: 14
Reputation: 125
Finally, I decided to give up axios, and to use vue-resource, I used an interceptor to add credential = true, like this, and it works fine.
In the main.js file :
Vue.http.interceptors.push(function(request) {
request.credentials = true
return function(response) {
};
});
Upvotes: -2