I have Drupal running in a docker container and nginx running in another container.
When I do the login call through postman or directly on the webserver cli it works perfectly.
But when I do call from within my application I get a timeout after 30 seconds.
From server:
wodby@php.container:/var/www/html $ curl -X POST
‘http://api.swappr.localhost/user/login?_format=json‘
-H ‘Postman-Token: a9c80844-ed69-4d24-b205-6475b7e469dc’
-H ‘cache-control: no-cache’
-d ‘{“name”:”logintest2@gmail.com”, “pass”:”password”}’
{“current_user”:{“uid”:”21″,”name”:”logintest2@gmail.com”},”csrf_token”:”yf5YBYyY4YvXCcufLyTWeKnvbhq5sdcZHpgmsVDeSRY”,”logout_token”:”PEarVS7vPi5idARarGQzrrXAYcJL9YkiXmoHw_a7yJE”}
In code:
$response = Drupal::httpClient()->post(
'http://api.swappr.localhost/user/login?_format=hal_json',
['name' => 'logintest2@gmail.com', 'pass' => 'password']
);
cURL error 28: Operation timed out after 30001 milliseconds with 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Anyone knows what could cause this problem?