If I use create fresh API token, do I (not) need to set the token in a cookie from Vue.js app? I saw many examples with Laravel Passport, but all of them show back feature only, without front.
There are various ways of doing the same, you can use cookies or local storage, Laravel Password mostly validates the request using token so if you are using Vue Auth at front end you can define a constructor to send the token every time you send a request.
constructor() {
let userToken = window.localStorage.getItem('token');
let userData = window.localStorage.getItem('user');
if (typeof userToken !== 'undefined' || typeof userData !== 'undefined') {
this.user = userData;
this.token = userToken;
} else {
this.user = null;
this.token = null;
}
if (this.token !== null && this.token !== 'undefined') {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token;
} else {
this.authenticated = false;
this.logout();
}