dev-only OTP exposure (console print + API response) switches off; cookies gain
secure+SameSite=strict; morgan switches to combined logging; helmet HSTS stays fully active.Run this (brew/Node) for each of JWT_SECRET, JWT_REFRESH_SECRET, COOKIE_SECRET:
terminal node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" # → 64 hex chars; one output per secret store, never reuseSecrecy rules: 32+ characters, unique per environment, and rotated on any leak suspicion.
NODE_ENV=production PORT=5000 API_PREFIX=/api/v1 MONGO_URI=your_atlas_connection_string JWT_SECRET=your_new_random_32_char_secret JWT_EXPIRES_IN=7d JWT_REFRESH_SECRET=your_other_new_random_32_char_secret JWT_REFRESH_EXPIRES_IN=30d COOKIE_SECRET=your_cookie_secret RESEND_API_KEY=re_your_api_key RESEND_FROM="Your Brand <noreply@yourdomain.com>" RESEND_REPLY_TO=support@yourdomain.com FRONTEND_URL=https://yourapp.com GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_CALLBACK_URL=https://api.yourapp.com/api/v1/auth/google/callbackFRONTEND_URL=https://yourapp.com— one origin only (it's the CORS allow-list). Sub-domains count as separate origins.On Vercel/Render/hosting, set:
NEXT_PUBLIC_API_URL=https://api.yourapp.com/api/v1
- Use Atlas with a lone IP allow-list entry: your backend host's outbound IP.
- A dedicated database user with least privileges; rotate if anyone with access leaves.
- Email is sent through Resend's HTTP API, so no SMTP ports are needed. Verify the sender domain in Resend, set RESEND_API_KEY/RESEND_FROM on the host, then run pnpm test:email from the deployed backend to confirm delivery.
- Cron/host-level backups: Atlas handles snapshots; verify retention for your tier.
0/90%
- Generate a new value (random 32+ chars).
- Update it wherever it lives (host env vars, .env, secret manager) — no code change needed.
- JWT secrets: rotating access secret invalidates live sessions → users re-login; rotate refresh secret too in the same window.
- Database password: change in Atlas → update MONGO_URI → restart (no migrations required).
- Google client secret: rotate inside Google Cloud Console (Goto Credential details → regenerate) then update .env + restart.
- Email credentials: rotate in the provider dashboard, update .env, re-run test-email.js.