react-geocode icon indicating copy to clipboard operation
react-geocode copied to clipboard

Google maps API key is exposed

Open kanandam opened this issue 1 year ago • 4 comments

Hi there, I'm using this library for geocoding purpose in my react code, and the API key is exposed in the request under query params, is there a way to encrypt or hide it in the request?

image

TIA...

kanandam avatar Jan 23 '24 09:01 kanandam

Hi, it's impossible and it has been a known issue for a long time. Community recommends to create and use a separate API key for each type of operations (e.g. one for geocoding, one for map rendering, etc.) to at least decrease the negative impact of only one key being abused with all types of operations by a malicious user.

ziyaddin avatar Jan 23 '24 17:01 ziyaddin

Hey @ziyaddin , I've been using this other library for google maps component, it uses some methods to create a security layer for the request api, just letting you know if it can help. https://github.com/JustFly1984/react-google-maps-api/tree/master/packages/react-google-maps-api

cheers...

kanandam avatar Jan 24 '24 04:01 kanandam

Hi there, I'm using this library for geocoding purpose in my react code, and the API key is exposed in the request under query params, is there a way to encrypt or hide it in the request? image

TIA...

Hi, It's not a problem to expose your api, you simply just restrict your apis from ip address or url website ... https://cloud.google.com/api-keys/docs/add-restrictions-api-keys

Aupire avatar Jan 30 '24 09:01 Aupire

@Aupire yes, I'm aware of restricting the API, but we don't have the access to the GCP to restrict, it's with client.

kanandam avatar Feb 01 '24 06:02 kanandam