I am running a copy of the website that I am working on, using a server that runs on localhost:8759. The website uses Google's address autocomplete capability. I have a script element at the bottom of the page with a URL of https://maps.googleapis.com/maps/api/js?key=XXXXXX&libraries=places
, with an actual API key in place of the XXXXXX
. The API key is restricted so it can only be used from our production and testing servers.
I would like it to work on localhost instead. Initially, I tried running the website on localhost, and the autocomplete didn't work. I saw an error on my console saying Google Maps API error: RefererNotAllowedMapError
.
I went to Google's Developer Console, added localhost:8759/*
to the list of referrers, and waited over 5 minutes as recommended by Google. The autocomplete still didn't work. I saw an error saying This API project is not authorized to use this API. Please ensure this API is activated in the Google Developers Console
.
I tried adding a key with no restrictions and using it. The autocomplete still didn't work. I got an error like the one mentioned in the previous paragraph.
The autocomplete works fine when it is on a page coming from our testing server (which has an IP address in the list of referrers) or production (which has a domain in the list of referrers), but I can't make it work on localhost.
How can I make it work?