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

milantarami's avatar

Laravel Sanctum App only working on Mozilla

I have laravel API hosted in api.domain.edu.np & react app hosted on app.domain.edu.np API is built on top of Laravel Sanctum

Problem The app works fine in Mozilla but on other browsers, I get 419 errors in API

API request

/csrf-cookie is OK

/api/v1/login ( returns 419 in all browsers except Mozilla Firefox )

.env configuration

CACHE_DRIVER=file 

SESSION_DRIVER=cookie

SESSION_LIFETIME=120    

SANCTUM_STATEFUL_DOMAINS=app.domain.edu.np    

SESSION_DOMAIN=.domain.edu.np

in localhost works in all browsers with below .env configuration

SANCTUM_STATEFUL_DOMAINS=localhost:3000

SESSION_DOMAIN=localhost
0 likes
5 replies
mabdullahsari's avatar

Are you sure cookies are being sent with every subsequent request? For example with axios, you have to set withCredentials or however it is called.

mabdullahsari's avatar

@milantarami Do you have the EnsureFrontendRequestsAreStateful middleware on the top of your middleware stack? If yes, then there is something wrong with your domain configuration.

1 like
milantarami's avatar

solved

@mabdullahsari i figured out the problem . The problem, I was accessing react app with https:// and API with http://

accessing React App & Laravel API both with either http:// or https:// worked fine

thanks for your comment & the term domain configuration :)

Please or to participate in this conversation.