Go through this: https://laravel.com/docs/9.x/sanctum#spa-authentication
And a simple example on security headers: https://danieldusek.com/enabling-security-headers-for-your-website-with-php-and-laravel.html
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
UPDATE OF MY POST
Even if I know quite well the basis of VueJS, my knowledge around security and deployment is very low. And that's the first time I try to deploy a VueJS frontend.
I have a Laravel app with a VueJS frontend in a separate environment but on the same domain.
Local Laravel API : localhost:8000 Frontend : localhost:3000 in production mode or localhost:8080 in dev mode
Laravel API : back.domain.com Frontend : front.domain.com
I have restarted the configuration from zero reading the Sanctum documentation. Now with both localhost:8000 and localhost:3000 it doesn't work. In fact the csrf-token is retrieved, but it is not sent in the HTTP headers when I try to log in. So I have a 419 error.
Axios is configured as below.
const api = axios.create({
baseURL: 'http://localhost:8000',
withCredentials: true,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
What should I check to solve this issue ?
Thanks a lot ;).
V
I have solved my issue ... it's not very simple to configure axios and sanctum and cors well at the first time. But I have set all well and it works.
The main problem was the configuration of the SESSION_DOMAIN for which I had specified the port and you have to not specify the port.
Please or to participate in this conversation.