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 GuzzleHttpExceptionConnectException: 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.
Advertisement
Answer
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.