Max execution time excedeed when trying to call API route in another API Platform

486 Views Asked by At

In a very specific context, I need to renew my JWT after performing some actions with API Platform. I didn't find an effective way to call another route directly and so I went through a curl request.

My problem is that I can't make this call from my controller directly (maximum waiting time exceeded), here is my code:

$client = HttpClient::create();
$response = $client->request('POST', "http://127.0.0.1:8000/api/auth/refresh", [
    'body'          => ['refresh_token' => $refresh_token],
    'timeout'       => 300,
    'max_redirects' => 0,
]);

var_dump($response);
die();

However, I have no problem calling my API route with Postman (http://127.0.0.1:8000/api/auth/refresh).

Does anyone have the solution to this problem?

Thank you in advance

1

There are 1 best solutions below

0
On

Is http://127.0.0.1:8000 running with the same app you are making the call from or there are two different servers running at the same time?

If it is the same app, you should refresh the token directly from the controller you are now trying to make the call from, or return a 401 status code to the frontend and handle it from there(Hit the refresh token route, make the call originally attempted again with the new token).