6 min read

Environment variable hygiene — Vercel / Netlify / Fly / Railway

Per-platform env-var setup with NEXT_PUBLIC_ guidance, secret manager recommendations, rotation cadence.

Where you put your env vars matters as much as what you put. Per-platform setup guide.

What it is

Cloud platforms differ in how env vars are stored, scoped, and protected. Vercel marks Sensitive; Netlify uses lock icon; Fly uses fly secrets; Railway uses references.

Vulnerable example

# .env committed to git
OPENAI_API_KEY=sk-proj-...
# Vercel env var with NEXT_PUBLIC_ prefix
NEXT_PUBLIC_STRIPE_SECRET=sk_live_...

Fixed example

# .gitignore
.env
.env.local
.env.production
.claude/
.cursor/
.continue/
# Vercel: mark Sensitive flag on every secret
# Fly: use fly secrets set; never fly.toml
# Rotate per /templates/env-var-hygiene

How Securie catches it

Securie findingcritical
.env.local:12

Environment variable hygiene

Secret_scanner + secrets-lifecycle specialists catch leaked secrets across all platforms; static-rules pre-filter scans .gitignore for missing patterns.

Suggested fix — ready as a PR
# .gitignore
.env
.env.local
.env.production
.claude/
.cursor/
.continue/
# Vercel: mark Sensitive flag on every secret
# Fly: use fly secrets set; never fly.toml
# Rotate per /templates/env-var-hygiene
Catch this in my repo →Securie scans every PR · ships the fix as a one-click merge · free during early access

Checklist

  • No NEXT_PUBLIC_ on secrets
  • Secrets in vendor's secret manager (not source)
  • Rotation cadence: 30/60/90 days per category
  • Per-key spend caps
  • .gitignore includes AI-tool dot-dirs

FAQ

Vercel Sensitive flag?

Marks the env var as not-readable from build logs. Always enable for secrets.

Related guides