-
Never commit sensitive keys to version control
- Use
.env.localfor local development (already in .gitignore) - Use
.env.exampleor.env.local.examplefor documentation with placeholder values
- Use
-
Use proper prefixes
NEXT_PUBLIC_*- For variables that can be exposed to the browser- All other variables - Server-side only, kept secret
-
Sensitive Variables (Keep Secret!)
SUPABASE_SERVICE_ROLE_KEY- Full admin access to your databaseUPLOADTHING_TOKEN- API access to your file upload service- Any other API keys or tokens without
NEXT_PUBLIC_prefix
-
Public Variables (Safe to expose)
NEXT_PUBLIC_SUPABASE_URL- Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY- Public anonymous key with RLS protectionNEXT_PUBLIC_SITE_URL- Your website URL
- Copy
.env.local.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>orbunx wrangler secret bulk <file.json> - Required keys:
SUPABASE_SERVICE_ROLE_KEY,UPLOADTHING_TOKEN,OPENROUTER_API_KEY,NEXT_PUBLIC_SUPABASE_URL,NEXT_PUBLIC_SUPABASE_ANON_KEY,NEXT_PUBLIC_SITE_URL - Use your actual values, not placeholders
-
.env.localis in.gitignore - No real API keys in
.env.example - No console.log of sensitive tokens
- Server-side keys only used in server components/API routes
- Regular key rotation for production environments
-
Immediately rotate the exposed keys
- Supabase: Project Settings > API > Regenerate keys
- UploadThing: Dashboard > Regenerate API key
-
Update all environments
- Local
.env.local - Vercel environment variables
- Any other deployments
- Local
-
Check for unauthorized usage
- Review Supabase logs
- Check UploadThing usage statistics
If you discover a security vulnerability, please email security@vibedev.id instead of using public issue trackers.