Guide ยท Google Maps API keys ยท Updated
Is My Google Maps API Key Safe in My Website? How to Restrict an Exposed AIza Key in Lovable, Bolt and v0 Apps
A Google Maps key in your website is not a mistake by itself. The map cannot load without it. The problem is a key with no limits. Then anyone can copy it from your page and use it on their own site, or on other Google APIs, and the bill goes to you. Here is what Google says, which keys are fine to show, the two settings to change, and how to check your live app.
1. Public is fine. Unrestricted is not
The Maps JavaScript API runs in your visitor's browser, so its key is always visible in your page. You cannot hide it. Google's answer is to limit what the key can do:
- Google says: always restrict your API keys with one type of application restriction and one or more API restrictions.
- Google also says: you are financially responsible for charges caused by abuse of unrestricted API keys.
- Google Cloud says: a standard API key with no API restrictions can be used with every API that accepts keys. With no application restriction, it can be used from anywhere.
Newer keys made in the Google Cloud console must have at least one API restriction. Older keys, and keys made some other ways, can still be wide open. AI builders often tell you to "create an API key" and paste it in, without the restriction step.
Sources: Google Maps Platform security guidance ยท Google Cloud: Manage API keys
2. Which Google keys can be in the browser
| Key used for | OK in the browser? | Restrict it with |
|---|---|---|
| Maps JavaScript API key (the map on your page) | Yes, it has to be | Websites (your domain) + only the Maps APIs you use |
| Maps Embed API key (an iframe map) | Yes | Only the Maps Embed API, plus Websites if you can |
| Maps Static / Street View Static key (map image URLs) | Yes, in the image URL | Websites + API restrictions, and sign URLs on the server |
| Geocoding, Places, Routes web service calls from your server | No | IP addresses or a server proxy, plus API restrictions |
| Gemini API key | No, never | Server only, restricted to the Gemini API |
- Web service keys are secret. Google says keys for web services (like Geocoding or Places called from your server) are not meant to be public. If your app calls those APIs straight from the browser with the same key as your map, move those calls to the server. Google suggests a proxy server for this.
- Use separate keys. Google says to use a separate key for each app, so one leak does not hit everything. A project can have up to 300 keys.
- Firebase is different. The
AIzakey in your Firebase config is public by design and your Security Rules protect your data. Do not reuse it for Maps. See Is my Firebase app secure?
3. Add the two restrictions (5 minutes)
- Open the Google Cloud console, go to Google Maps Platform โ Credentials, and click your key.
- Application restrictions: choose Websites. Add your live domain with
https://, for examplehttps://yourapp.comandhttps://*.yourapp.comfor subdomains like www. If your app also runs on a preview link (like a lovable.app, netlify.app or vercel.app address), add that too while you need it. - API restrictions: choose Restrict key and tick only what your site uses. For a normal map that is Maps JavaScript API. If you use the Places search box add Places API (New) or Places API; if you use the Geocoding service add Geocoding API.
- Click Save, wait a few minutes, then open your live site and check the map still loads. The browser console will name anything you missed.
- In APIs & Services, turn off any API you do not use. Google says unused services left on are open to abuse, and API restrictions only cover one key.
Not sure which APIs your key really uses? Google's Metrics explorer can show usage per key (filter by credential_id), and the Credentials page may suggest restrictions for you.
Sources: Google Maps Platform: Restrict your API keys ยท Google Cloud: Add application restrictions
4. The Gemini catch
Many vibe-coded apps use Google for both maps and AI. Both use keys that start with AIza and can live in the same Google Cloud project. That is where it goes wrong:
- A key with no API restrictions works with any API that accepts keys in that project, so it can reach more than your map.
- Google says the Gemini API now rejects unrestricted standard keys. But a key that lists the Gemini API (Generative Language API) in its restrictions still works.
- So if your builder ticked the Gemini API on the same key your map uses, your public key can run AI calls on your bill.
Fix: keep the Gemini API off every key that is in your website. Call Gemini only from a server function with its own key. Details: Is my Gemini API key safe in my frontend?.
Sources: Google AI: Using Gemini API keys ยท Google Cloud: Standard API keys
5. Cap the bill
- Quotas stop charges. Google Maps Platform lets you lower the daily quota for each API. When the cap is hit, requests stop instead of costing more.
- Budgets only warn you. Budgets and budget alerts send you an email. They do not stop usage.
- Set a quota a bit above your normal daily use, and a budget alert, before you share your app widely.
6. Check your live app in 60 seconds
Only check apps you own or have permission to test.
- Fastest: paste your live link at the top of this page. VibeCheck reads your homepage and the JavaScript files it loads and lists any Google API key (
AIza...) it finds, masked. - By hand in Chrome: open your live site, right-click โ Inspect, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search for
AIza. Count how many different keys you see. More than one is a hint that a web service or Gemini key slipped into the browser. - Search for
generativelanguage.googleapis.com,geocode/jsonandplaces.googleapis.com. If those calls come from the browser with your key, move them to the server (prompt 1 below). - Then open the key in the Google Cloud console and confirm both restrictions from section 3 are set.
What VibeCheck can and cannot see: it finds the key in your public code, but it cannot see your Google Cloud settings and it never uses your key. So it marks a Google key as low risk and leaves the restriction check to you.
7. Seeing strange usage? Do this now
- Restrict the key first (section 3). Google lists this as the first step.
- Look at usage per key in the Metrics explorer. Usage on APIs you do not use, or from places you do not expect, means someone else has it.
- Still being abused after restricting? Rotate it: open the key, click Rotate key, put the new key in your app, redeploy, then delete the old key. Google says both keys work during the switch, so your map does not go down.
- Lower your quotas while you sort it out, and scan your live site again.
More detail for every key type: I leaked my API key. What do I do now?
Source: Google Maps Platform: Handle unauthorized use of an API key, Be careful when rotating API keys
8. Copy-paste fix prompts
Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. Your builder cannot change your Google Cloud settings, so do section 3 yourself too.
Find every Google API key (anything starting with AIza) and every call to maps.googleapis.com, places.googleapis.com, routes.googleapis.com and generativelanguage.googleapis.com in this project. Keep only ONE key in the browser, used only to load the Maps JavaScript API (or Maps Embed), read from a VITE_ or NEXT_PUBLIC_ variable named GOOGLE_MAPS_BROWSER_KEY. Move every Geocoding, Places web service, Routes, Distance Matrix and Gemini call into a server function (Supabase Edge Function or Next.js Route Handler) that reads a separate key from a server-only secret named GOOGLE_SERVER_KEY. Require sign-in or add a per-visitor limit on those server functions. List every key that was in client code so I can restrict or replace it in the Google Cloud console.
Update my server function that calls Google Maps web services: build the Google request on the server with only the fields my app needs. Do not let the browser pass a full Google URL, an API name or a key. Return only the data my page uses. Add a limit of 30 requests per visitor per minute and return 429 when it is hit. Show me the changed code.
My app shows Maps Static API or Street View Static API images. Generate those image URLs on the server and add a digital signature using a signing secret stored as a server-only secret. Never put the signing secret in frontend code or a VITE_ / NEXT_PUBLIC_ variable. Show me where the URL is built now and the new server code.
9. Check it for me
Paste your link into VibeCheck. In about 10 seconds it checks the JavaScript your live site sends to visitors for leaked keys (Google AIza, OpenAI, Stripe sk_live_, Supabase service_role and more), checks if your public Supabase key can read open tables, and checks security headers, SEO basics and broken links.
It is a public, read-only check. It never asks for your code, your login or your Google account.
Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.
No tool can promise your app is 100% secure. VibeCheck catches common, costly mistakes before a stranger does.
10. FAQ
Is it safe to have my Google Maps API key in my website?
For the Maps JavaScript API, the key has to be in the browser, so anyone can see it. That is normal. What makes it safe is restricting it. Google says to always give the key one application restriction (Websites, with your own domain) and API restrictions (only the Maps APIs you use). An unrestricted key can be copied and used on other sites and other Google APIs, and you pay for it.
Who pays if someone uses my leaked Google Maps key?
You do. Google says you are financially responsible for charges caused by abuse of unrestricted API keys. That is why restrictions matter more than hiding the key. You can also set daily quota limits on each Maps API, which stop usage at a cap. Budgets and budget alerts only email you, they do not stop charges.
Can someone use my public Maps key to call Gemini?
Only if the key is allowed to. A standard Google API key with no API restrictions works with any API that accepts keys in that project. Google now says the Gemini API rejects unrestricted standard keys, but a key that has the Gemini API (Generative Language API) on its allowed list still works. So keep Gemini off every public key, and use a separate server-side key for Gemini.
What restrictions should I put on my Google Maps key?
In the Google Cloud console, open Google Maps Platform, then Credentials, and edit the key. Under Application restrictions pick Websites and add your real domain, like https://yourapp.com and https://*.yourapp.com. Under API restrictions pick Restrict key and tick only the Maps APIs your site uses, like Maps JavaScript API and Places API. Save, then test your live site.
Is my Firebase apiKey the same as a Google Maps key?
Both start with AIza, but they do different jobs. Firebase says the key it makes for your web app is fine to be public, and your Security Rules are what protect your data. Google says to use a separate, restricted key for Maps, not the Firebase key.
How do I check if my live app shows a Google API key?
Paste your live link into VibeCheck for a free scan. It reads your homepage and the JavaScript it loads and lists any Google API key (AIza...) it finds, masked. It cannot see your Google Cloud settings, so it marks the key as low risk and you check the restrictions yourself. By hand: open DevTools, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search for AIza.
More questions? See the VibeCheck FAQ. Related guides: How to check if your API key is exposed ยท I leaked my API key. What do I do now? ยท Is my OpenAI key safe? (Gemini too) ยท Is my Firebase app secure? ยท Is NEXT_PUBLIC_ safe for API keys? ยท Is my Lovable app safe? ยท Is my Bolt app secure? ยท Is my v0 app secure? ยท Vibe coding security checklist.