• Resolved Michael Svanstr?m

    (@squeezeday)


    I receive the following error when using the plugin on https://localhost when connecting via IPv6

    Nets API Error: {"errors":{"notifications.WebHooks[0].Url":["Field is not accepted as a valid URL"]}}

    Fix:

    
    // diff.diff
    --- classes/requests/helpers/class-dibs-requests-get-notifications.php  2020-03-13 12:39:31.845641900 +0100
    +++ classes/requests/helpers/class-dibs-requests-get-notifications.new.php      2020-03-13 12:39:27.228442700 +0100
    @@ -12,9 +12,8 @@
    
            public static function get_web_hooks() {
                    $web_hooks = array();
    -
                    // Only set web hooks if host is not local.
    -               if ( isset( $_SERVER['REMOTE_ADDR'] ) && '127.0.0.1' === $_SERVER['REMOTE_ADDR'] ) {
    +               if ( isset( $_SERVER['REMOTE_ADDR'] ) && in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'] ) ) {
                            return $web_hooks;
                    } else {
                            $web_hooks[] = array(
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Krokedil

    (@krokedil)

    Hi,

    You need to have a public address available as it doesnt work with localhost.

    Best regards

    Andreas

    Thread Starter Michael Svanstr?m

    (@squeezeday)

    Please take a look at the provided diff. The error only occurs when browsing to https://localhost over ipv6 (::1), not ipv4 (127.0.0.1). My diff fixes this error.

    Obviously I browse https://localhost for development purposes only using php -S localhost:80

    Regards,
    Michael

    Plugin Contributor Krokedil

    (@krokedil)

    Hi @squeezeday

    When implementing the code example you provided in earlier message does it still works as expected with ipv4? Webhooks should not be set if environment is local.

    Best Regards,
    Kristian Andersson

    Thread Starter Michael Svanstr?m

    (@squeezeday)

    Yes. With the provided diff no web hooks will be set for localhost regardless of using ipv4 or ipv6.

    Please look at (your) comment in the diff
    // Only set web hooks if host is not local.

    Plugin Contributor Krokedil

    (@krokedil)

    Hi @squeezeday

    Could you please make a PR to the dibs-easy-for-woocommerce repository with your fix? We will look into it next week.

    https://github.com/krokedil/dibs-easy-for-woocommerce

    Thanks in advance.

    Best Regards,
    Kristian Andersson

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Webhooks error message on ::1’ is closed to new replies.