Skip to content

My Google Maps key leaked. What do I do?

Short answer

A Maps JavaScript key in your page isn't a leak by itself, because Google expects it to be public. The risk is an unrestricted key, which anyone can use for any enabled Google API on your bill. Add website (HTTP referrer) and API restrictions now. If you see abuse, regenerate the key and set quotas and budget alerts.

Last updated 2026-11-25 · Reviewed by ProofForge

Is it this key?

Format: AIza (39 characters). Public by design for the Maps JavaScript API when restricted.

Blast radius: An unrestricted key works for every API enabled in the project (Maps, Places, Geocoding, and others), billed to you.

The first 10 minutes

WhenDoHow
0–3 minRestrictCloud console → APIs & Services → Credentials → edit the key. Add Website restrictions (your domains) and API restrictions (only the Maps APIs you use).
3–6 minCheck billingLook at API metrics and Billing for spikes in Places, Geocoding or other APIs.
6–8 minRegenerate if abusedRegenerate or create a new key, deploy it, then delete the old one.
8–10 minCap itSet per-API quotas and a budget alert. Use a separate IP-restricted key for server-side calls.

Stop the next leak

  • Keep the key in a server-side env var. Never use a VITE_, NEXT_PUBLIC_ or EXPO_PUBLIC_ variable or hard-code it in frontend code.
  • Call the provider from your backend or an edge function, and add .env* to .gitignore.
  • Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed .env or .git paths.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

My key is in page source. Do I need to hide it?

No. You can't hide a browser key. Restrict it instead.

Why did restricting break my map?

Missing referrer or API in the lists. See /errors/google-maps-key-restriction.

Same key for Gemini?

Don't reuse keys across APIs. Restrict each key to one purpose.

Sources

Related

Read as Markdown · Scan methodology