Overview
Environment variables in Centinela are:- Build-time variables: Embedded during the Vite build process
- Prefixed with
VITE_: Required for Vite to expose them to the client - Accessed via
import.meta.env: Standard Vite environment access pattern
Required Variables
VITE_APP_NAME
Application identifier used to select the correct backend and frontend URLs from the routing configuration.
"Centinela"- Water treatment monitoring system (primary)"Mas Agua"- Alternative water management system"Cooptech"- Parent platform integration"Reconecta"- Reconnection management
src/modules/alert/views/index.jsx:23
src/modules/Charts/views/ConfigGraphic.jsx:79
src/utils/routes/app.routes.js.
VITE_ENTORNO
Deployment environment that controls API endpoints, cookie settings, and feature flags.
"local"- Development on localhost"desarrollo"- Development/staging server"produccion"- Production environment
src/modules/LoginApp/view/LoginCooptech.jsx:34-35
Production environments use secure cookies with
SameSite=None, while development uses non-secure cookies with SameSite=Lax for easier testing.SECRET
Secret key used for authentication, token signing, and other security operations.
- Minimum 32 characters recommended
- Use cryptographically random values
- Keep different secrets for each environment
- Never commit secrets to version control
Environment Configuration
Backend Route Configuration
TheVITE_ENTORNO and VITE_APP_NAME variables work together to select the correct backend URL:
src/utils/routes/app.routes.js:40-44
Frontend Route Configuration
src/utils/routes/app.routes.js:21-25
Setting Environment Variables
Docker Build
Pass environment variables as build arguments:Docker Compose
Create adocker-compose.yml file:
docker-compose.yml
.env file (do not commit this):
.env
Local Development
For local development with Vite, create a.env.local file:
.env.local
.env.local during development:
Environment Variable Reference
Complete Variable List
| Variable | Type | Required | Example | Description |
|---|---|---|---|---|
VITE_APP_NAME | string | Yes | "Centinela" | Application identifier for routing |
VITE_ENTORNO | string | Yes | "produccion" | Deployment environment |
SECRET | string | Yes | "a1b2c3..." | Security secret key |
Additional Optional Variables
While not in the Dockerfile, these variables are referenced in the codebase:Controls offline mode behavior. Set to
"sin" to enable offline menu caching.src/modules/NavBarCustom/views/index.jsx:115
URL to redirect to when returning to the Cooptech platform.
src/context/TabContext.jsx:45
Verifying Environment Variables
After building, you can verify the environment variables were applied:During Build
Check the build output for environment variable references:In Browser Console
Access environment variables in the browser console:Inspect Built Files
Best Practices
Use different secrets per environment
Never reuse secrets between development, staging, and production.
Rotate secrets regularly
Change production secrets on a regular schedule and after any security incident.
Use environment-specific files
Maintain separate
.env.development, .env.staging, and .env.production files.Document required variables
Keep a
.env.example file with all required variables (without actual secrets).Troubleshooting
Variables Not Available
Wrong Environment Detected
If the application connects to the wrong backend:- Verify
VITE_ENTORNOis set correctly - Check the value matches exactly:
"local","desarrollo", or"produccion" - Rebuild the Docker image with correct build args
- Clear browser cache and hard reload
Secrets Not Working
If authentication fails:- Ensure the
SECRETmatches between frontend and backend - Verify the secret was passed during Docker build
- Check that the secret is sufficiently long and random
- Confirm no whitespace or special characters are breaking the value
Next Steps
Docker Deployment
Build and deploy with Docker containers
Nginx Configuration
Configure the Nginx web server
