user5843610
user5843610

Reputation:

Google reCAPTCHA in China

My site is using Google reCAPTCHA control but I am hearing its being block in China, Is there anyway around this I see there is some people reporting that changing the API to https://www.recaptcha.net works in China?

Anyone try this because I see it still going out to google?

string apiUrl = "https://www.recaptcha.net/recaptcha/api/siteverify?secret={0}&response={1}";

enter image description here

Upvotes: 21

Views: 29135

Answers (5)

Ashish Thakur
Ashish Thakur

Reputation: 1

Google's reCAPTCHA service will load a script from https://www.gstatic.cn instead of https://www.gstatic.com In my case CSP blocks gstatic.cn so reCAPTCHA do not work in China.

Upvotes: -1

Arm144
Arm144

Reputation: 773

As google says in his assistance page, you should use this domain "www.recaptcha.net" instead "www.google.com" on the api call.

  • First, replace src="https://www.google.com/recaptcha/api.js" with src="https://www.recaptcha.net/recaptcha/api.js"
  • After that, apply the same to everywhere else that uses "www.google.com/recaptcha/" on your site.

Obtained from: https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally

Edit: to clarify on some of the comments, while if you try it outside of china yes you do get references to gstatic.com but if you try this in china, any references to gstatic.com are replaced with gstatic.cn (don't forget to add it to your SCP). So this solution is still valid.

Upvotes: 20

Manish
Manish

Reputation: 962

I have shared the solution to this problem by using cURL.

https://stackoverflow.com/a/63568516/11910869

cURL acts as a middle man between the client and the server. So even if google.com/recaptcha can not be accessed by the client because it is blocked by the service provider, cURL can act as the proxy to send the HTTP requests and get the response.

Upvotes: 1

John
John

Reputation: 3545

IMHO, google things are not stable in China as it can be blocked anytime. From Baidu threads, it also mentioned that sometime google recaptcha works, sometime it doesn't. https://www.v2ex.com/t/492752 (Chinese)

In programming world ,unstable function means useless or more code for dealing with exception.

If you really need to use google recaptcha, you would better test properly using VPN (IP in China) first.

Here are some options you can consider,

  1. You can use alternative captcha

    Google will tell you various captcha.

  2. Build your own captcha

Open Source Invisible reCAPTCHA alternatives

  1. Use proxy web server(nginx) to send and receive data to or from google recaptcha

Upvotes: 7

Related Questions