I have 5 applications that use the same sanctum API for authentication. What I really want to do is to make a POST request sanctum API from another application. I do GET requests like the below and it's working. But when I make a POST request it returns csrf token mismatch error.
So could someone please tell me is it possible to make a post request into a sanctum API via Client?
$response = $client->get('http://localhost:8000/api/user', [
'headers' => [
'accept' => 'application/json',
'cookie' => $request->header('cookie'),
'referer' => $request->header('referer'),
]
]);
Thanks
i use
Bearerinstead ofcookie, in sanctum laravel reads access tokens fromAuthorizationin header.this is how i make request from laravel client to sanctum (an example of my code):
i send my headers with method
withHeadersas an associative array and send my post body withpostmethod second argument.read more here : https://laravel.com/docs/9.x/http-client