cancel
Showing results for 
Search instead for 
Did you mean: 

google recaptcha cross-origin error after form submission

google recaptcha cross-origin error after form submission

I have built a module displaying some content and have put a newsletter signup form at the bottom protected by google recaptcha.  The first time a person visits the page the recaptcha loads and the user can check the "i am not a robot" box to submit the form.  However once a person submits the form the page loads and the reacptcha is removed from the page with a cross-origin error in the browser debug console. Magento ver. 2.4.3-p2

 

 

Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.
at Y.Ip (https://www.gstatic.com/recaptcha/releases/3TZgZIog-UsaFDv31vC4L9R_/recaptcha__en.js:786:479)
at Array.<anonymous> (https://www.gstatic.com/recaptcha/releases/3TZgZIog-UsaFDv31vC4L9R_/recaptcha__en.js:43:12)
at Object.init (https://www.gstatic.com/recaptcha/releases/3TZgZIog-UsaFDv31vC4L9R_/recaptcha__en.js:794:313)
at https://www.google.com/recaptcha/api2/bframe?hl=en&v=3TZgZIog-UsaFDv31vC4L9R_&k=6Lfn7dsUAAAAAPPCPlnv6ODpxI7lnd3c3AuYFGKu:184:30

 

To add to the confusion it is only happening on this page, and only on the production instance of the application. other identical instances (staging, dev, localhost sandbox) all work without error after submitting the form.  There are other pages on the site that have the same newsletter signup form and they all work fine. it is just this one (module)page on this one server instance.  what could the problem be?

 

not working: https://in-situ.com/us/customer-stories (submit the form once and it will never load captcha again; will load briefly then get immediately removed with cross-origin error)

working: https://in-situ.com/us/agriculture

 

3 REPLIES 3

Re: google recaptcha cross-origin error after form submission

Hi @qodeqrashgde80 ,

 

On customer stories page I can see below error in console.

Uncaught Error: reCAPTCHA has already been rendered in this element

 

So, seems like it happens because of same thing calling multiple times.

Other pages I can't see same error.

 

Please check code for re-captcha that you are using on customer stories page and avoid re-calling or re-initialization for the same.

 

Problem Solved? Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

nothing

nothing

Re: google recaptcha cross-origin error after form submission

The problem is not solved. I had to use a workaround (reinitialize the recaptcha a second or so after dom ready).  A strange thing about the problem is that you have to submit the form once, then it will never load on the page again.  You can do this many times with new incognito windows.

 

this only happens in this environment and no other identical environments. it is very strange.