marksitko / vue-sanctum

MIT License
11 stars 1 forks source link

401 unaunthenticated "me" #3

Closed icangku closed 2 years ago

icangku commented 3 years ago

its not working at all

Vue.prototype.$http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
Vue.prototype.$http.defaults.headers.common['Accept'] = 'application/json';
axios.defaults.baseURL = window.location.origin + '/api/admin';
axios.defaults.withCredentials = true
Vue.use(VueSanctum, {
    axios: axios,
    store,
    fetchUserAfterLogin:true,
    routes: {
        csrf: '../../sanctum/csrf-cookie',
        login : 'auth/login',
        logout : 'auth/logout',
        me : 'auth/me'
    }
});
icangku commented 3 years ago

I console the "authenticated" but it false, how to determine its aunthenticated or not?

marksitko commented 3 years ago

I think the problem is your baseURL or rather than the csrf path. It does not work like a directory path where you can step through levels with ....

try this:

axios.defaults.baseURL = window.location.origin + '/';
Vue.use(VueSanctum, {
    axios: axios,
    store,
    fetchUserAfterLogin:true,
    routes: {
        csrf: 'sanctum/csrf-cookie',
        login : 'api/admin/auth/login',
        logout : 'api/admin/auth/logout',
        me : 'api/admin/auth/me'
    }
});