Security Best Practices
Follow these guidelines to keep your maps.guru integration secure in production.
API Key Security
Never Expose Keys in Client-Side Code
// BAD — key visible in browser source
const map = new maplibregl.Map({
style: `https://api.maps.guru/v1/styles/basic/style.json?key=mapx_secret_key`
});
Instead, proxy through your backend:
// GOOD — key stays on your server
const map = new maplibregl.Map({
style: '/api/map-style' // Your backend fetches with the API key
});
Use Environment Variables
# .env (never committed)
MAPS_GURU_API_KEY=mapx_your_key
// server.js
const apiKey = process.env.MAPS_GURU_API_KEY;
Separate Keys Per Environment
| Environment | Key Name | Scopes |
|---|---|---|
| Development | Dev Key | All |
| Staging | Staging Key | All |
| Production | Prod Backend | geocoding, routing |
| Production | Prod Maps | maps |
HTTPS Only
All maps.guru endpoints enforce HTTPS. Never use HTTP — it exposes your API key in transit.
Restrict Key Scopes
Follow the principle of least privilege:
- If an application only needs geocoding, create a key with only the
geocodingscope - If a frontend only displays maps, use a key with only the
mapsscope - Never use the default all-scopes key in production
Monitor Usage
Set up monitoring to detect anomalies:
- Check daily — Review the usage dashboard for unexpected spikes
- Set alerts — Configure budget warnings in the admin dashboard
- Audit keys — Regularly review which keys exist and revoke unused ones
Rotate Keys Regularly
Establish a key rotation schedule:
- Create a new key
- Deploy the new key to your application
- Verify everything works
- Revoke the old key
- Repeat quarterly (or after any team member departure)
Incident Response
If you suspect a key has been compromised:
- Revoke immediately — Go to Dashboard → API Keys → Revoke
- Create a new key — Generate a replacement
- Update applications — Deploy the new key
- Review usage — Check for any unauthorized requests
- Audit access — Review who had access to the compromised key
Warning
Key revocation is instant and permanent. All requests using the revoked key will fail immediately.