recaptcha icon indicating copy to clipboard operation
recaptcha copied to clipboard

api.js from recaptcha.net not working

Open xiayanzheng opened this issue 3 years ago • 0 comments
trafficstars

Issue description

I have a system based on processwire, recently this system was deployed in China. https://www.google.com/recaptcha/api.js is not working in china but if I open my system page from outside china api.js from google works properly, to solve this issue I changed the api.js URL from https://www.google.com/recaptcha/api.js to https://www.recaptcha.net/recaptcha/api.js but it's not working, Recaptcha didn't show up. but https://www.recaptcha.net/recaptcha/api/siteverify works well.

Environment

  • OS name and version:Ubuntu 20.04
  • PHP version:7.4
  • Web server name and version:Apache2
  • google/recaptcha version: recaptcha2
  • Browser name and version:Edge Version 101.0.1210.47 (Official build) (arm64)

Reproducing the issue

  • URL (optional):
  • Code (optional): below is the code that my system used for load recaptcha in PHP. if i set SITE_RECAPTCHA_API_URL to https://www.google.com/recaptcha/api.js the "grecaptcha is ready!" message will pop up, if set SITE_RECAPTCHA_API_URL to https://www.recaptcha.net/recaptcha/api.js nothing happen.
const SITE_RECAPTCHA_API_URL = "https://www.recaptcha.net/recaptcha/api.js";
elseif(isset($this->data_recaptcha_type) && $this->data_recaptcha_type == 'recaptchav2') {
            $params = '?onload=renderInvisibleCallback&render=explicit';
            $return = "
                <script>
                var renderInvisibleCallback = function() {
                    alert("grecaptcha is ready!");    
                };
                </script>";
            $return .= "<script src='".self::SITE_RECAPTCHA_API_URL."$params' async defer></script>";
        }
 return $return;

User steps

No error message found.

xiayanzheng avatar May 20 '22 16:05 xiayanzheng