Reputation: 603
I have run
php artisan serve
and my laravel app is resolved on localhost:8000 successfully
Laravel Sanctum configuration
SESSION_DRIVER=cookie
SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost:8080
My vue app is resolved on localhost:8080
async loginUser() {
try {
await this.$axios.get('/csrf-cookie');
await this.$axios.post('/login', this.payload);
this.$router.push("/verify/account");
} catch(error) {
let errors = error.response.data.errors;
for (let field of Object.keys(errors)) {
this.$toast.error(errors[field][0], 'error');
}
}
},
This works and the user is logged in but GET, POST request returns a 401 unauthenticated all the time. I've checked the request headers and the cookie and X-XSRF-TOKEN are sent but i get a 401 everytime.
Upvotes: 0
Views: 259
Reputation: 603
It would seem a token still needs to be sent for the request, if the Vue app were embedded just the cookies work, if cookies aren't present it checks for a token. Sanctum is much leaner than Passport but Stateless and Stateful auth works.
Upvotes: 1