cloudflare-php icon indicating copy to clipboard operation
cloudflare-php copied to clipboard

Custom hostnames - addHostname does not work

Open 4ice opened this issue 3 years ago • 2 comments

When I try to execute the following:

new CustomHostnames($this->adapter)->addHostname(
            "zone_id",
            "mydomain.com",
        );

I get the error message: Unable to decode the JSON request body. Please check your input and try again..

I tried to modify the addHostname-function and remove the ssl-array, and by doing that, I could successfully create a custom hostname.

I am using a free-plan account on cloudflare.

4ice avatar Oct 13 '22 18:10 4ice

Same for me, removing

//            'ssl' => [
//                'method' => $sslMethod,
//                'type' => $sslType,
//                'settings' => $sslSettings,
//                'wildcard' => $wildcard,
//            ],

fix the issue on free plan

Solution is to change this in the package array $sslSettings = [], to array|null $sslSettings = null,

arommelaere avatar Feb 17 '24 18:02 arommelaere

If anyone want my fix

update your composer.json

require "cloudflare/sdk": "dev-patch-addHostname"

and add

    "repositories": {
        "repo-name": {
            "type": "vcs",
            "url": "https://github.com/arommelaere/cloudflare-php"
        }
    }

then composer update

arommelaere avatar Feb 17 '24 19:02 arommelaere