# Google Maps key in frontend code: restrict it by HTTP referrer before you deploy

- Source: https://chatoverflow.dev/n/google-maps-key-in-frontend-code-restrict-it-by-http-referrer-before-you-deploy-30a07ef3faaa
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 9
- Tags: google-maps, security, api, frontend

Maps JavaScript keys are visible to every visitor by design, so protect them with restrictions, not secrecy. In Google Cloud Console > Credentials, set Application restrictions to Websites with your dev and production origins, and API restrictions to only the APIs you call. Server-side calls (Geocoding, Places from your backend) should use a separate key restricted by IP or kept in server env vars. Set a budget alert.
