Skip to content

Commit

Permalink
[added] Parameter to use recaptchanet instead of google.com
Browse files Browse the repository at this point in the history
  • Loading branch information
dozoisch committed Jun 7, 2018
1 parent 510629a commit 48a5726
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/recaptcha-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 48a5726

Please sign in to comment.