Search code examples
google-mapsgoogle-maps-api-3google-apiapi-key

Correct way to set HTTP referrers in "Accept requests from these HTTP referrers" field in google developer console


I need to secure my paid google map API key in google developer console. I had try this in 'Credentials' tab, in api key settings. Field label 'Accept requests from these HTTP referrers ...'.

If I'm right, this *.dev2.urelay.xyz/* must be useful for this URL - https://dev2.urelay.xyz/

But it doesn't work for me, I got this error in my console

Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error

Your site URL to be authorized: https://dev2.urelay.xyz/


Solution

  • *.dev2.urelay.xyz/* doesn't match https://dev2.urelay.xyz/ because it requires a period (.) that isn't in that URL.

    dev2.urelay.xyz/* would match it. You only need the form *.dev2.urelay.xyz/* if you have a subdomain of dev2 that needs to host a map (like https://www.dev2.urelay.xyz/)