diff --git a/README.md b/README.md index e8b6c51..1057493 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,13 @@ Other properties can be used to customise the rendering. In order to translate the reCaptcha widget, you should create a global variable configuring the desired language. If you don't provide it, reCaptcha will pick up the user's interface language. +If google.com is blocked, you can set useRecaptchaNet to `true` so that the component uses recaptcha.net instead. + ```js window.recaptchaOptions = { - lang: 'fr' -} + lang: 'fr', + useRecaptchaNet: true, +}; ``` ## Component API diff --git a/src/recaptcha-wrapper.js b/src/recaptcha-wrapper.js index f11589b..1a5b500 100644 --- a/src/recaptcha-wrapper.js +++ b/src/recaptcha-wrapper.js @@ -2,10 +2,11 @@ import ReCAPTCHA from "./recaptcha"; import makeAsyncScriptLoader from "react-async-script"; const callbackName = "onloadcallback"; -const lang = typeof window !== "undefined" && (window.recaptchaOptions && window.recaptchaOptions.lang) ? - `&hl=${window.recaptchaOptions.lang}` : - ""; -const URL = `https://www.google.com/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`; +const options = (typeof window !== "undefined" && window.recaptchaOptions) || {}; + +const lang = options.lang ? `&hl=${options.lang}` : ""; +const hostname = options.useRecaptchaNet ? "recaptcha.net" : "www.google.com"; +const URL = `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`; const globalName = "grecaptcha"; export default makeAsyncScriptLoader(ReCAPTCHA, URL, {