{"success":true,"name":"restrict-browser-exposed-api-keys-by-domain-api-and-quota","description":"Putting a maps, analytics, or SaaS API key into frontend code","category":"ai-brimind","path":"ai-brimind/restrict-browser-exposed-api-keys-by-domain-api-and-quota/SKILL.md","file":"SKILL.md","content":"---\nname: restrict-browser-exposed-api-keys-by-domain-api-and-quota\ndescription: \"Putting a maps, analytics, or SaaS API key into frontend code\"\n---\n\n# Restrict Browser-Exposed API Keys by Domain, API, and Quota\n\n## When to use\nA third-party service key (maps, geocoding, client-side APIs) must ship in the frontend, where anyone can read it, and you are configuring that key.\n\n## Example request\nA maps key pasted into the frontend with no restrictions → anyone copies it from view-source and burns your quota on their own site; keys must be locked to your domains (referrer restriction). One key used for maps, geocoding, and other APIs → a leak exposes every capability at once; enable only the specific APIs each key needs (API scoping). No usage cap on a pay-per-use key → abuse turns into a surprise invoice; quotas and billing alerts bound the damage (spend limits). A server-only key reused in the browser 'to save setup time' → server keys grant far more power; browser and server keys must be separate credentials (key separation).\n\n## Instructions\nAct like a developer who accepts a hard truth: any key shipped to the browser is public, period — so its safety must come from restrictions, not from hiding. First split roles: keys embedded in frontend code are a separate credential from server keys, and anything with sensitive power stays server-side behind your own endpoint. For the keys that legitimately live in the browser, configure the provider's restriction options one by one: lock the key to your exact domains or app identifiers (HTTP referrer / application restrictions), enable only the specific APIs that feature uses, and set usage quotas plus billing alerts so abuse hits a ceiling instead of your card. Keep per-environment keys (development, production) so a leaked dev key never touches production quota. Check the provider's dashboard for these controls before writing any code — they exist on all major platforms and cost nothing. Revisit keys periodically: unused APIs disabled, old keys rotated, referrers still correct after domain changes. Only ship once the copied-from-view-source version of your key is useless on anyone else's site, and explain how domain locks, scoping, and quotas — not secrecy — are what make a public key safe to be public.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #577\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}