1

I'm using amp-iframe in a page with a Google map in the iframe. The page works fine and validates on all the browsers I tried, except Safari on MacOS.

I get this error in the console:

Refused to get unsafe header "AMP-Access-Control-Allow-Source-Origin"

I tried adding these headers to my server:

Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Headers AMP-Access-Control-Allow-Source-Origin
Header set Access-Control-Expose-Headers AMP-Access-Control-Allow-Source-Origin
Header set AMP-Access-Control-Allow-Source-Origin https://example.com

However, I still see the same error. It only occurs in Safari. It seems CORS related. Anyone can help?

Sanchit Gupta
  • 3,148
  • 2
  • 28
  • 36
rodders
  • 354
  • 1
  • 11
  • Based from this [link](https://stackoverflow.com/a/5837798/5832311), only [simple response headers](https://www.w3.org/TR/cors/#simple-response-header) are exposed when using CORS. There is also a [reported bug](https://github.com/webcomponents/webcomponentsjs/issues/407) in Safari 10. However, it was stated that it should not affect the runtime of your application. It's just a [log](https://github.com/webcomponents/webcomponentsjs/blob/7911bb7827474999b46aec95606b6a246bb5d745/src/HTMLImports/xhr.js#L35-L44) by `console.error`. – abielita Jul 23 '17 at 13:44
  • If you're still having this issue, can you post a link to a sample page with the issue? – Andrew Aug 18 '17 at 15:41

1 Answers1

0

I had a similar issue embedding a Google Calendar, it resolved when I added both allow-scripts and allow-same-origin to the sandbox attribute. This sample comes from the <amp-iframe> doc:

<amp-iframe width="200" height="100"
    sandbox="allow-scripts allow-same-origin"
    layout="responsive"
    frameborder="0"
    src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDG9YXIhKBhqclZizcSzJ0ROiE0qgVfwzI&q=iceland">
</amp-iframe>

If this does not address your issue, could you edit your question to include your <amp-iframe> code so we can help?

stealththeninja
  • 3,576
  • 1
  • 26
  • 44