Earlier i tried this approach stackoverflow post but it gives 419 issue on local
'api' => [
// do not resolve Session store not set on request issue register user
// \App\Http\Middleware\EncryptCookies::class,
// \Illuminate\Session\Middleware\StartSession::class,
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
So after following laravel docs. I came to know sanctum.php and figured out the exact issue. And remove those two lines from kernel.php
Solution: Set APP_URL correctly in environment variables as being used to set stateful domains in /config/sanctum.php. If issue is on production use production domain.
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))),