Secrets Management — Never Leak API Keys
The #1 cause of security incidents? Accidental API key commits to public GitHub repos:
The Correct Pattern:
```cmd
REM 1. Create .env file
echo NEXT_PUBLIC_FIREBASE_KEY=your_key > .env.local
echo DATABASE_URL=postgresql://... >> .env.local
echo JWT_SECRET=ultra-secret-string >> .env.local
REM 2. IMMEDIATELY add to .gitignore
echo .env >> .gitignore
echo .env.local >> .gitignore
echo .env*.local >> .gitignore
REM 3. Create .env.example (safe to commit — shows structure)
echo NEXT_PUBLIC_FIREBASE_KEY=your_key_here > .env.example
echo DATABASE_URL=postgresql://localhost/mydb >> .env.example
`
In Node.js:
```javascript
require('dotenv').config()
console.log(process.env.DATABASE_URL) // reads from .env
`
For Deployments (Vercel/Firebase):
```cmd
npx vercel env add DATABASE_URL
npx firebase functions:config:set db.url="postgresql://..."
`
Treat .env files like passwords — never share, never commit! 🔐
