ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

Google Map with <amp-iframe> #38556

Open Davidfredette opened 1 year ago

Davidfredette commented 1 year ago

Description

When using amp-iframe to insert a google map and user click on the link to open the map or the streetview to fullscreen into a new tab, the navigator return an error of cross-origin opener policy

Reproduction Steps

See the issue at https://fenetresdrummond.ca/ the map is located at the bottom of the page in the footer.

Relevant Logs

No response

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

Jozebel11 commented 1 year ago

The site https://fenetresdrummond.ca/ needs control over the domain it is trying to iframe. If google-maps has restricted Cross-Origin requests then there isn't much that can be done.

Otherwise you can try install cors to the https://fenetresdrummond.ca/ package.json and amend the Access-Control-Allow-Origin to allow google maps like this Access-Control-Allow-Origin: 'https://google.com/maps' or allow any site using Access-Control-Allow-Origin: *

Keep in mind cors policies protect you and your site from Cross Site Request Forgery.

I hope this is helpful, please let me know if this works for your issue.