WooCommerce Webhook: invalid URL WooCommerce Webhook: invalid URL wordpress wordpress

WooCommerce Webhook: invalid URL


For WooCommerce version 3.3.5, Bjorn's solution doesn't seem to work.

In my case, I had to eddit the file wp-content/plugins/woocommerce/includes/class-wc-webhook.php:185, method deliver.

Comment the wp_safe_remote_request method, and instead, use the insecure http request method.

// Webhook away!$http_call = _wp_http_get_object();$response = $http_call->request( $this->get_delivery_url(), $http_args );//$response = wp_safe_remote_request( $this->get_delivery_url(), $http_args );


It is not the custom port, but localhost.

There is a check in wp-includes/http.php wp_http_validate_url() that rejects all kinds of local IPs unless specifically allowed with a filter on http_request_host_is_external that returns true...

Cheers,Björn


in the following function

/** * Validate a URL for safe use in the HTTP API. * * @since 3.5.2 * * @param string $url * @return false|string URL or false on failure. */

comment this line

if ( isset( $parsed_home['host'] ) ) {        //$same_host = ( strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ) || 'localhost' === strtolower( $parsed_url['host'] ) );        $same_host = false;    } else {        $same_host = false;    }

and if you're using another port for example in laravel you have to add the port here

if ( empty( $parsed_url['port'] ) )        return $url;    $port = $parsed_url['port'];    if ( 80 === $port || 443 === $port || 8080 === $port || 8000 === $port )        return $url;    if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port )        return $url;    return false;}