# 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

| When | Do | How |
|---|---|---|
| 0–3 min | Restrict | Cloud console → APIs & Services → Credentials → edit the key. Add Website restrictions (your domains) and API restrictions (only the Maps APIs you use). |
| 3–6 min | Check billing | Look at API metrics and Billing for spikes in Places, Geocoding or other APIs. |
| 6–8 min | Regenerate if abused | Regenerate or create a new key, deploy it, then delete the old one. |
| 8–10 min | Cap it | Set 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.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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

- [Google Maps Platform security guidance](https://developers.google.com/maps/api-security-best-practices)
- [Google Cloud: Manage API keys](https://cloud.google.com/docs/authentication/api-keys)

## Related

- [Fix Google Maps RefererNotAllowedMapError / ApiTargetBlocked](/errors/google-maps-key-restriction)
- [Gemini key leaked: first 10 minutes](/leaked-keys/gemini)
- [Fix: secrets in VITE_ / NEXT_PUBLIC_ vars](/fix/vite-env-secrets)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
