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