Environment Variable Storage
Environment variables are stored as a Map in the Project model:Using MongoDB Map type allows flexible key-value storage without predefined schemas.
Setting Environment Variables
Environment variables can be set during deployment creation:Static Sites (Build-Time Variables)
For static sites, environment variables are injected during the Docker build process:Variable Injection
Dockerfile Integration
Node.js Applications (Runtime Variables)
For Node.js apps, environment variables are passed to the container at runtime:Container Environment
Node.js environment variables are available through
process.env and can be updated without rebuilding.Updating Environment Variables
Update environment variables through the project settings API:Retrieving Environment Variables
Get current environment variables:Redeployment with Updated Variables
When environment variables change during redeployment:- Fetches latest environment variables from database
- Rebuilds image (static) or recreates container (Node.js)
- Injects updated variables into build/runtime
Security Best Practices
Secrets Management
DO:
- Use environment variables for API keys, tokens, passwords
- Never commit secrets to Git
- Rotate secrets regularly
- Hardcode secrets in source code
- Share secrets in plain text
- Use the same secrets for dev/prod
Recommended Variable Naming
Framework-Specific Variables
Vite (React, Vue, Svelte)
Variables must be prefixed withVITE_:
Create React App
Variables must be prefixed withREACT_APP_:
Next.js
Public variables must be prefixed withNEXT_PUBLIC_:
Node.js / Express
No prefix required:Common Environment Variables
Backend Services
Frontend Applications
Validation Rules
Debugging Environment Variables
Check Build Logs
For static sites, verify variables are injected:Inspect Container Environment
For Node.js apps:Common Issues
Variable not accessible in frontend:- ❌
API_URL- No prefix - ✅
VITE_API_URL- Correct prefix
- Check spelling and case
- Verify it’s set in project settings
- For static: Rebuild required
- For Node.js: Redeploy required
API Reference
Get Environment Variables
Update Environment Variables
This endpoint replaces all environment variables. Include all keys you want to keep.
Limitations
- No built-in encryption (store sensitive data carefully)
- Variables visible to project owner in API responses
- No versioning or history tracking
- Static sites require rebuild for changes to take effect
Best Practices Summary
1
Use Descriptive Names
Name variables clearly:
DATABASE_URL not DB2
Prefix Frontend Variables
Use
VITE_, REACT_APP_, or NEXT_PUBLIC_ prefixes3
Separate Environments
Use different values for development, staging, production
4
Never Commit Secrets
Keep
.env files out of version control5
Redeploy After Changes
Remember to redeploy for changes to take effect