title: Make localhost API Request with Symfony Client?
body: <p>I am trying with Symfony 5 to make a request on my API developed with API Platform.</p>
  <p>The URL in question is <a href="https://127.0.0.1:8000/api/cheeses" rel="nofollow noreferrer">https://127.0.0.1:8000/api/cheeses</a></p>
  <p>When I do a GET request on it with Postman, everything works nicely. And if i'm going to the url in my browser, it works to. But impossible to make the request in PHP with Symfony. I went about it like this :</p>
  <pre class="lang-php prettyprint-override"><code>use Symfony\Contracts\HttpClient\HttpClientInterface;
  
  class AbstractService
  {
  
     public function __construct(private HttpClientInterface $client){}
  
     protected function request(string $method, string $path, array $params = [])
      {
  
          $response = $this-&gt;client-&gt;request('GET', 'https://127.0.0.1:8000/api/cheeses', [
              'headers' =&gt; [
                  'Content-Type' =&gt; 'application/json',
              ]
          ]);
  
          dd(json_decode($response-&gt;getContent(), true, 512, JSON_THROW_ON_ERROR));
      }
  
  }
  </code></pre>
  <p>When I try it loops and I get the error :</p>
  <blockquote>
  <p>Idle timeout reached for &quot;https://127.0.0.1:8000/api/cheeses&quot;.</p>
  </blockquote>
  <p>But if I'm trying with external URL like <strong><a href="https://api.github.com/repos/guzzle/guzzle" rel="nofollow noreferrer">https://api.github.com/repos/guzzle/guzzle</a></strong>, it works.</p>
  <p>My <strong>nelmio_cors</strong> config :</p>
  <pre class="lang-yaml prettyprint-override"><code>nelmio_cors:
      defaults:
          origin_regex: true
          allow_origin: ['*']
          allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
          allow_headers: ['Content-Type', 'Authorization']
          expose_headers: ['Link']
          max_age: 3600
      paths:
          '^/': null
  </code></pre>
  <p>Any idea ?</p>