question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught SecurityError in Google iframe when unmounting

See original GitHub issue

When the component gets unmounted (e.g., when navigating to a different page using react-router), an exception occurs:

Uncaught SecurityError: Blocked a frame with origin "https://www.google.com" from 
accessing a frame with origin "localhost". The frame requesting access has a protocol 
of "https", the frame being accessed has a protocol of "http". Protocols must match.

Possible solution is to remove the iframe container inserted by the reCAPTCHA script in componentWillUnmount.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
laserpantscommented, Oct 21, 2015

@bobiblazeski Assuming Google hasn’t changed the widget in some way that would affect this, the second solution I suggested should still work as long as you only have one component:

componentWillUnmount() {
  Array.prototype.slice.call(document.getElementsByTagName('IFRAME')).forEach(element => {
    if (element.src.indexOf('www.google.com/recaptcha') > -1 && element.parentNode) {
      element.parentNode.removeChild(element);
    }
  });
}
0reactions
bobiblazeskicommented, Oct 21, 2015

@johanneshilden Many thanks will use that as temporary solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Googles recaptcha gives "Uncaught SecurityError" after ...
At the end of the document there is a div containing all iframe recaptchas. Removing that div solves the problem but that feels...
Read more >
cypress-io/cypress - Gitter
"Uncaught SecurityError: Failed to set the 'domain' property on 'Document': Assignment is forbidden for sandboxed iframes." If the iframe src contains a 3rd ......
Read more >
Error: Permission denied to access property 'target'
In Google chrome and firefox, this error occurs as a DOMException, and in Safari, it occurs as a security error. The same origin...
Read more >
Uncaught SecurityError: Blocked a frame with origin “https ...
I am using google reCaptcha v2.0 and this is working in the same domain when i am trying to do it with a...
Read more >
localStorage Security Issue Cannot Use Polyfill - Google Groups
Put a page in an iframe (for example, an ad or Facebook Canvas application) ... An exception is thrown: "Uncaught SecurityError: Failed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found