Laravel API Post request CSRF token mismatch from localhost

Viewed 482

I have my Laravel API hosted on https://api.example.com & a separate Nuxt app hosted on https://frontend.example.com both works fine.

But when I make post requests to my API from localhost nuxt app (localost:3000) I am getting 419 csrf token mismatch error. I am using sanctum for API auth.

But I don't know why I am getting csrf issue here since I have defined all the routes in api.php file. The strange thing is that it is working perfectly in the cloud server but doesn't work from localhost. I have my cors config as below -

    'paths' => ['*'],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => ['*'],

    'allowed_headers' => ['*'],

    'exposed_headers' => ['*'],

    'max_age' => 0,

    'supports_credentials' => true,
0 Answers
Related