CRITICAL: Never commit your .env.local file to version control!
-
Get an API Key:
- Visit https://makersuite.google.com/app/apikey
- Create a new API key
- Copy the
.env.exampleto.env.local - Replace the placeholder with your actual key
-
API Key Restrictions:
- Set HTTP referrer restrictions in Google Cloud Console
- Limit the API key to only Gemini API access
- Regularly rotate your API keys
- Monitor usage in the Google Cloud Console
- This app stores the API key in browser localStorage
- Users can inspect the code and extract the key
- For production: Implement a backend proxy to hide the API key
User Browser β Your Backend API β Google Gemini API
(with auth) (key hidden)
β PDF file validation (type and size) β Input sanitization via ReactMarkdown β No SQL injection risk (no database) β HTTPS recommended for deployment β Environment variable management
If you discover a security vulnerability, please email the maintainer directly instead of creating a public issue.
- API key stored in environment variables
-
.env.localin.gitignore - API key restrictions set in Google Cloud Console
- HTTPS enabled on hosting platform
- Regular dependency updates (
npm audit fix) - Content Security Policy headers configured
- Rate limiting enabled (if using backend)
Run regular security audits:
npm audit
npm audit fixUpdate dependencies regularly:
npm update
npm outdated- Immediately revoke the exposed key at https://console.cloud.google.com/apis/credentials
- Generate a new API key
- Add restrictions to the new key
- Update your
.env.localfile - If pushed to GitHub, consider the key permanently compromised
- Check your API usage for any unauthorized activity