0

I'm using the sanity php client to fetch some data off of sanity.

This is my query:

$results = $client->fetch(
    '*[_type == "article" && slug.current == $slug ]{name, intro}[0]',
    ['slug' => $slug]
);

This is the error I'm getting:

Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: 
Connection refused for URI https://someProject.api.sanity.io/v2021-03-25/data/query/public?query=someQuery 
in /www/htdocs/w01bd9f6/dev/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:321 

The odd thing is: everything works fine in my local dev environment. but testing this on the webserver results in the error. I added the CORS origins so both localhost and the Webserver are allowed to connect to sanity. php versions are the same.

bstnhnsl
  • 119
  • 5
  • 1
    Perhaps the webserver doesn't allow outgoing http connections (or only allows them to a set of whitelisted destinations). Check the firewall, or contact the system adminstrator. N.B. CORS is irrelevant here because you're making the request from PHP, not via AJAX. – ADyson Jun 22 '21 at 08:20

1 Answers1

0

I set up a .htaccess so the webserver php parses html files. Apparently Guzzle didn't like that. When I changed my files to .php everything worked as expected.

bstnhnsl
  • 119
  • 5