Im using docker (from symfony docs - https://github.com/dunglas/symfony-docker) and in symfony 6 i've reciceved:
Failed to connect to localhost port 443 after 0 ms: Connection refused for "https://localhost/products".
This addres in browser returns json with products.
This is controller:
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpFoundation\JsonResponse;
class ApiController extends AbstractController
{
#[Route('/apire', name: 'api')]
public function fetchGitHubInformation()
{
$client = HttpClient::create();
$response = $client->request('GET', 'https://localhost/products');
$content = $response->getContent();
$content = $response->toArray();
return new JsonResponse($content);
}
}
and this is netstat from caddy docker container:
/srv/app # netstat -tulpn | grep LISTEN
tcp 0 0 127.0.0.11:45991 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:2019 0.0.0.0:* LISTEN 1/caddy
tcp 0 0 :::443 :::* LISTEN 1/caddy
tcp 0 0 :::80 :::* LISTEN 1/caddy
Where is the problem?