-
Never commit sensitive keys to version control
- Use
.env.localfor local development (already in.gitignore) - Use
.env.examplefor documentation with placeholder values
- Use
-
Use the current prefixes
VITE_*— values Vite inlines into the browser bundleNEXT_PUBLIC_SITE_URL— live server/SEO site URL (legacy name, still required)- All other variables — server-only. Read them through
getServerRuntimeSecrets()on Workers.
-
Sensitive variables (keep secret)
DATABASE_URL— Neon pooled connection stringBETTER_AUTH_SECRET— Better Auth signing secretGOOGLE_CLIENT_SECRET/GITHUB_CLIENT_SECRET— OAuth secretsUPLOADTHING_TOKEN— file upload API accessOPENROUTER_API_KEY/RESEND_API_KEY— optional provider keys
-
Public variables (safe to expose)
VITE_SITE_URL/NEXT_PUBLIC_SITE_URL— website URLVITE_BETTER_AUTH_URL— public auth callback URL
- Copy
.env.exampleto.env.local - Fill in your actual values
- Never commit
.env.local
- Set runtime secrets with Wrangler (never commit them):
bunx wrangler secret put <NAME>orbun run scripts/sync-wrangler-secrets.ts - Required runtime keys:
DATABASE_URL,BETTER_AUTH_SECRET,BETTER_AUTH_URL,NEXT_PUBLIC_SITE_URL, plus OAuth and upload keys when those features are enabled - Do not put
DATABASE_URL_UNPOOLEDon the Worker. Keep it in local.env.localfor schema tools. VITE_*values are inlined at build time. Rebuild before deploy when they change.
-
.env.localis in.gitignore - No real API keys in
.env.example - No
console.logof sensitive tokens - Server-only keys are read via
getServerRuntimeSecrets(), notprocess.envon Workers - Regular key rotation for production environments
-
Immediately rotate the exposed keys
- Neon: rotate the connection string
- Better Auth: generate a new
BETTER_AUTH_SECRET - UploadThing: Dashboard → regenerate token
- OAuth: rotate Google/GitHub client secrets
-
Update all environments
- Local
.env.local - Worker secrets
- Any other deployments
- Local
-
Check for unauthorized usage
- Review Neon query logs
- Check UploadThing usage statistics
If you discover a security vulnerability, please email security@vibedev.id instead of using public issue trackers.