We've recently implemented Google's Customer Review module into our success page.

However, the console bugs. It keeps telling me:

jquery.js:2998 Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://my-dev-domain.tld" from accessing a cross-origin frame.

I understand that this is a problem from CORS, and therefore I added the following to my .htaccess: Header set Access-Control-Allow-Origin "*"

However, this also didn't worked. The error is still showing.

Deactivating FPC hasn't changed something.

I've learned that there's a fix for page-cache.js in future versions of Magento (> 2.1.5, see https://github.com/magento/magento2/pull/8005).

However, copying the new PR to the staging system doesn't resolve the error, it still bugs.

How could I now solve my problem?

Btw, this is the code I inject:

In head:


In body:

<script type="text/javascript">
  window.renderOptIn = function() {
    window.gapi.load('surveyoptin', function() {
          "merchant_id": "xxxxxxxxx",
          "order_id": "<?= $data['orderid']; ?>",
          "email": "<?= $data['email']; ?>",
          "delivery_country": "<?= $data['country_id']; ?>",
          "estimated_delivery_date": "<?= $data['delivery_date']; ?>"


  • we are on Magento 2.0.4
  • when trying to use my solution on a Magento 2.1.5 system nothing gets shown, nor is there an error in the console
  • Did you install on Apache? – Phoenix128_RiccardoT Apr 21 '17 at 15:04
  • Yes, Apache2 is running. – Max Apr 22 '17 at 14:30
  • Is your apache supporting OPTIONS directive? – Phoenix128_RiccardoT Apr 22 '17 at 21:49

If you are right and problem is CORS:

Use the following directives on your apache:

RewriteEngine On                  
RewriteRule ^(.*)$ $1 [R=200,L]

Also add:

Header always set Access-Control-Allow-Origin "*"                   
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"

While using CORS request, your server will be asked to answer to OPTIONS requests by your browser. If you do non condigure it for a correct answer, the "preflight" check will fail.

If it works you can restrict origins.

Hope it helps.

  • Gonna check this on monday, would be great if its working! – Max Apr 23 '17 at 11:32
  • Worked, but now Google throws a 404. Wtf? :D – Max Apr 24 '17 at 12:36
  • What does it mean that Google throws a 404? – Phoenix128_RiccardoT Apr 24 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.