Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fat4441's avatar

Got error 419 page expired on initial breeze / api install (laravel 11)

I just install laravel 11, then i install breeze with the API only option, but when i checked using postman to post /register i got 419 page expired, it is fresh install so i thought it will just work out of the box, anything that i miss? and other step that i did is adding Laravel\Sanctum\HasApiTokens to user model trait.

I also do some search fist about this error, and most of them is CSRF problem from their frontend apps like the csrf token is not being put in the form body, but I can't find my case which is API only laravel, and i found nothing in the middleware (still fresh install)

0 likes
2 replies
puklipo's avatar
puklipo
Best Answer
Level 9

Before creating a Laravel project, you should understand the difference between Sanctum's API Token Authentication and SPA Authentication.

Breeze API stack is not designed for general API-only use. It is designed for Sanctum's SPA Authentication. SPA Authentication is stateful, so CSRF is required. Don't be fooled by the "API" name.

To create a general stateless API, run the php artisan install:api command in a new project without any starter kit. You will have to create the authentication functionality yourself.

fat4441's avatar

@puklipo ah i see, i also found articles about it that i need to perform pre request to get the csrf token from this endpoint /sanctum/csrf-cookie didn't know about that, thanks

Please or to participate in this conversation.