Google Maps API HTTP Restrictions: how to use wildcards?
Asked Answered
M

2

5

Based on documentation here

I added http restrictions using wildcards like so:

This should cover all paths for all subdomains, but I receive RefererNotAllowedMapError error when I try to use https://www.dev.mydomain.com/#/

I even tried explicitly adding https://www.dev.mydomain.com/#/, but I get same error.

I am totally lost and have no idea what to do. Clearly other people are using Google Maps APIs and not leaving them totally unrestricted so there has to be a way to do this.

Moonshot answered 21/6, 2019 at 23:40 Comment(3)
What is the URL the error message indicates needs to be authorized?Overwrought
https://www.dev.mydomain.com/#/Moonshot
I'm voting to close this question as off-topic because it is about the use of a third-party service and not about programming.Shew
S
9

Try adding these two HTTP restrictions instead:

  1. *.mydomain.com/*

  2. mydomain.com/*

These two will allow your API key to be used in all sub-domains and paths in your website.

Adding (*.) before your domain will allow something like "www.mydomain.com" or "dev.domain.com" to access your API key.

Adding (*) after your domain will allow something like "domain.com/path" to access your API key.

Steadman answered 24/6, 2019 at 4:16 Comment(1)
I wonder whether the trailing wildcard is required. In my tests, only having leading wildcards is enough; the API still works on domain.com/path.Biak
F
0

Bit late for OP but adding this for posterity/future visitors. I don't think wildcards work for multi-level subdomains. In order to enable www.dev.yourdomain.com you would need to either add it verbatim or use a wildcard to allow any subdomain of dev.yourdomain.com, i.e. *.dev.yourdomain.com

Fibril answered 14/6, 2023 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.