0๐
โ
I solved it by adding the headers to the axios configuration:
import axios from 'axios'
import store from '@/store/index'
export function http() {
return axios.create({
baseURL: store.state.api.apiURL,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer
${localStorage.getItem('accessToken').replace(/['"]+/g, '')}`
}
})
}
I get the accessToken from the localstorage and every time the page is reloaded the information is refreshed and does not appear anymore unauthorized
0๐
sanctum login is depend on cookies not local storage
you must add with_credential: true
to axios options
and it is good to use this library to make authintication https://www.npmjs.com/package/vue-sanctum
Source:stackexchange.com