Skip to content

Commit ffda0aa

Browse files
authored
Merge pull request dozoisch#85 from dozoisch/recaptcha_net
[added] Parameter to use recaptchanet instead of google.com
2 parents 510629a + 48a5726 commit ffda0aa

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ Other properties can be used to customise the rendering.
6969

7070
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.
7171

72+
If google.com is blocked, you can set useRecaptchaNet to `true` so that the component uses recaptcha.net instead.
73+
7274
```js
7375
window.recaptchaOptions = {
74-
lang: 'fr'
75-
}
76+
lang: 'fr',
77+
useRecaptchaNet: true,
78+
};
7679
```
7780

7881
## Component API

src/recaptcha-wrapper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import ReCAPTCHA from "./recaptcha";
22
import makeAsyncScriptLoader from "react-async-script";
33

44
const callbackName = "onloadcallback";
5-
const lang = typeof window !== "undefined" && (window.recaptchaOptions && window.recaptchaOptions.lang) ?
6-
`&hl=${window.recaptchaOptions.lang}` :
7-
"";
8-
const URL = `https://www.google.com/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`;
5+
const options = (typeof window !== "undefined" && window.recaptchaOptions) || {};
6+
7+
const lang = options.lang ? `&hl=${options.lang}` : "";
8+
const hostname = options.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
9+
const URL = `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`;
910
const globalName = "grecaptcha";
1011

1112
export default makeAsyncScriptLoader(ReCAPTCHA, URL, {

0 commit comments

Comments
 (0)