0

I'm using google place API to fetch the google photo reference and I already got that and I used it like https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=PHOTOREFHERE&key=YOUR_API_KEY

And it's working fine in img tag, but the problem lies where the img tag src is exposing my key into URL

Does anyone have any idea how can I use the google place photo URL without exposing my key ?

Axel Blaz
  • 29
  • 7
  • [Restrict your API key](https://developers.google.com/maps/api-security-best-practices). – MrUpsidown Sep 15 '21 at 15:12
  • 2
    Duplicate of [How do I securely use Google API Keys](https://stackoverflow.com/questions/39625587/how-do-i-securely-use-google-api-keys) – MrUpsidown Sep 16 '21 at 08:00

1 Answers1

0

There are really two options:

  1. Restrict API key, enable only the Places API, Adjust quota for API to match expected usage. Use key on frontend.
  2. Proxy the requests (see https://stackoverflow.com/a/63618936/3145360) and optionally restrict API key with server IP
Justin Poehnelt
  • 2,992
  • 1
  • 19
  • 23