Authenticate User from Laravel

System Information
  • 3.1.0-alpha.5:
  • OsX Sonoma:
  • Sqlite:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I am trying to authenticate a user into my strapi server with this code, but always said that the connection to localhost:1337 is refused.
BTW: works from Postman but doesn’t work from Laravel App

$headers = [
‘Content-Type: application/json’,
// 'Authorization: Bearer ’ . $this->api_token,
];

        $params = [
            "identifier" => $identifier,
            "password" => $pasword,
        ];

        $curl = curl_init();
        
        curl_setopt_array($curl, array(
          CURLOPT_URL => $this->api_url . 'auth/local',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_POSTFIELDS => json_encode($params),
          CURLOPT_HTTPHEADER => $headers,
        ));
        
        $response = curl_exec($curl);