Back to course

Secrets Management

How to do that?

Well,

  1. Never hardcode secrets in your codebase, use environment variables or dedicated secrets managers.
  2. Rotate secrets regularly to minimize exposure if compromised.
  3. Use .gitignore and .env files to prevent secrets from being exposed in version control.
  4. Use tools like AWS Secrets Manager, HashiCorp Vault, or Kubernetes Secrets for management in production.

Example:

const apiKey = process.env.API_KEY;
if (!apiKey) {
  throw new Error('API Key not set in environment variables');
}

Want to learn more? Check out the 12 Factor App - Config