Google Map API key fails restrictions when editing in Cornerstone

I have a Google Maps API key that is restricted to my domain. The restrictions are working correctly, because the key works in other contexts, such as ACF’s Google Map element. The map also loads when viewing the page on the frontend. However, when editing the page in Cornerstone, the map fails to load and developer console shows:

Google Maps JavaScript API error: RefererNotAllowedMapError

Does the editor proxy data through another domain, or using another method that needs to be added to the restrictions?

Hi Andy,

Thanks for reaching out.
The RefererNotAllowedMapError error code occurs due to the following reason:

The current URL loading the Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key in the Cloud Console.

I would suggest you go through the error in the following URL and check the settings as mentioned.

https://developers.google.com/maps/documentation/javascript/error-

Hope it helps.
Thanks

Hello Tristup,

That is correct that the error means that the referring URL isn’t allowed. However, to my knowledge, the referring URL is allowed. I’ve whitelisted the domain and every URL under it. Other admin-side URLs are able to use that same API key, and the map works when the same page is viewed on the frontend. The only place that the map won’t load is within the Cornerstone editor.

Hey Andy,

You may need to include the Cornerstone URL like http://example.com/cornerstone/edit/ because the API restricts some URL which is why it displays on the frontend but not when using the Cornerstone Builder preview.

Thanks.

Hello,

Thank you for the response. However, the domain previously had all subfolders/URLs included. When explicitly whitelisting /cornerstone/edit, the error persisted. Could there be some caching within the Pro/Cornerstone editor causing this?

Does adding *:// as the protocol in your google api settings help?

image

Interestingly, that fixed it. I had previously had it in the api settings as bothhttps://example.com and example.com, with the same behavior. I haven’t been receiving mixed-content warnings on the site itself, but does the map component load something over http?

Either way, thank you!

Hey Andy,

We’re glad that we’re able to help you with your issue.

Cheers!

Google Maps will load in an iframe when in Cornerstone which recently has been causing issues like you see. I think due to some Google change. I already had http in my settings, but it wouldn’t work without *://. It’s come up before and we’ll update our docs on info about this. Have a great day.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.