This document explains how to properly manage environment variables in this project.
Environment variables often contain sensitive information such as:
- API keys
- Database credentials
- Email passwords
- Service tokens
- Other secrets
Committing these to version control creates security risks:
- Anyone with access to the repository can see the secrets
- Secrets can be exposed in public repositories
- Secrets remain in the git history even if removed later
- Different environments (development, staging, production) need different values
-
Use
.env.exampleas a template- This file contains the structure but with placeholder values
- It should be committed to the repository
-
Create your local
.envfilecp .env.example .env
-
Edit your
.envfile with your actual valuesnano .env # or use any text editor -
The
.envfile is now in.gitignoreand won't be committed
If you've already committed .env files to the repository, you can use the provided script to remove them from tracking:
./remove-env-from-git.shThis script will:
- Create backups of your current
.envfiles - Remove them from git tracking without deleting the local files
- Provide instructions for committing the changes
For different environments, you can create specific files:
.env.development- Development environment.env.test- Testing environment.env.production- Production environment
These are all ignored by git.
For Netlify deployment, set environment variables in the Netlify dashboard:
- Go to Site settings > Build & deploy > Environment
- Add each variable from your
.envfile
For GitHub Pages or other static hosting:
- Use GitHub Secrets for GitHub Actions workflows
- Reference these secrets in your workflow files
The project uses these environment variables:
| Variable | Purpose | Example |
|---|---|---|
| SMTP_HOST | SMTP server for email | smtp.gmail.com |
| SMTP_PORT | SMTP port | 587 |
| SMTP_SECURE | Use TLS | false |
| SMTP_USER | SMTP username/email | your-email@example.com |
| SMTP_PASS | SMTP password | your-password |
| ADMIN_EMAIL | Email to receive feedback | admin@example.com |
| SEND_EMAILS_IN_DEV | Send emails in dev mode | true/false |
- Never commit real credentials to the repository
- Regularly rotate secrets and credentials
- Use different credentials for different environments
- Limit access to production credentials
- Consider using a secrets manager for production