Environment Variables
Environment Variables
Section titled “Environment Variables”This guide covers all environment variables used in IONFLOW Frontend.
Overview
Section titled “Overview”Environment variables are managed using Vite’s built-in support. All variables must be prefixed with VITE_ to be exposed to the application.
Configuration Files
Section titled “Configuration Files”| File | Purpose | Git Tracked |
|---|---|---|
.env | Default values | Yes |
.env.local | Local overrides | No |
.env.development | Development mode | Yes |
.env.production | Production mode | Yes |
.env.[mode].local | Mode-specific local | No |
Variable Reference
Section titled “Variable Reference”API Configuration
Section titled “API Configuration”# Backend API URLVITE_API_URL=http://localhost:8000/api
# API VersionVITE_API_VERSION=v1
# Gateway API URLVITE_GATEWAY_URL=http://localhost:8001Authentication (Keycloak)
Section titled “Authentication (Keycloak)”# Keycloak Server URLVITE_KEYCLOAK_URL=http://localhost:8080
# Keycloak RealmVITE_KEYCLOAK_REALM=ionflow
# Keycloak Client IDVITE_KEYCLOAK_CLIENT_ID=ionflow-frontend
# Enable Keycloak (true/false)VITE_KEYCLOAK_ENABLED=trueFeature Flags
Section titled “Feature Flags”# Enable Vue DevToolsVITE_ENABLE_DEV_TOOLS=true
# Enable debug modeVITE_DEBUG_MODE=false
# Enable mock APIVITE_MOCK_API=falseApplication Settings
Section titled “Application Settings”# Application titleVITE_APP_TITLE=IONFLOW
# Default language (en/es)VITE_DEFAULT_LOCALE=en
# Items per page defaultVITE_DEFAULT_PAGE_SIZE=20Usage in Code
Section titled “Usage in Code”Accessing Variables
Section titled “Accessing Variables”// Direct accessconst apiUrl = import.meta.env.VITE_API_URL;
// With type safetyconst config = { apiUrl: import.meta.env.VITE_API_URL as string, isDebug: import.meta.env.VITE_DEBUG_MODE === 'true',};Type Definitions
Section titled “Type Definitions”Add to env.d.ts:
/// <reference types="vite/client" />
interface ImportMetaEnv { readonly VITE_API_URL: string; readonly VITE_API_VERSION: string; readonly VITE_KEYCLOAK_URL: string; readonly VITE_KEYCLOAK_REALM: string; readonly VITE_KEYCLOAK_CLIENT_ID: string; readonly VITE_KEYCLOAK_ENABLED: string; readonly VITE_ENABLE_DEV_TOOLS: string; readonly VITE_DEBUG_MODE: string; readonly VITE_APP_TITLE: string; readonly VITE_DEFAULT_LOCALE: string;}
interface ImportMeta { readonly env: ImportMetaEnv;}Environment-Specific Configurations
Section titled “Environment-Specific Configurations”Development
Section titled “Development”VITE_API_URL=http://localhost:8000/apiVITE_KEYCLOAK_URL=http://localhost:8080VITE_ENABLE_DEV_TOOLS=trueVITE_DEBUG_MODE=trueStaging
Section titled “Staging”VITE_API_URL=https://staging-api.ionflow.com/apiVITE_KEYCLOAK_URL=https://staging-auth.ionflow.comVITE_ENABLE_DEV_TOOLS=trueVITE_DEBUG_MODE=falseProduction
Section titled “Production”VITE_API_URL=https://api.ionflow.com/apiVITE_KEYCLOAK_URL=https://auth.ionflow.comVITE_ENABLE_DEV_TOOLS=falseVITE_DEBUG_MODE=falseSecurity Considerations
Section titled “Security Considerations”Do NOT expose
Section titled “Do NOT expose”- API keys or secrets
- Database credentials
- Private encryption keys
- Internal service URLs
Safe to expose
Section titled “Safe to expose”- Public API endpoints
- Feature flags
- UI configuration
- Public Keycloak settings
Build-Time vs Runtime
Section titled “Build-Time vs Runtime”Environment variables are replaced at build time. This means:
// ✅ Works - variable is replacedconst url = import.meta.env.VITE_API_URL;
// ❌ Won't work - dynamic accessconst key = 'VITE_API_URL';const url = import.meta.env[key];Docker Configuration
Section titled “Docker Configuration”For Docker deployments, pass variables at runtime:
# DockerfileARG VITE_API_URLENV VITE_API_URL=$VITE_API_URL
RUN pnpm build# Build with variablesdocker build --build-arg VITE_API_URL=https://api.example.com -t ionflow .CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”jobs: build: steps: - name: Build env: VITE_API_URL: ${{ secrets.API_URL }} VITE_KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }} run: pnpm buildTroubleshooting
Section titled “Troubleshooting”Variables Not Available
Section titled “Variables Not Available”- Ensure prefix is
VITE_ - Restart development server after changes
- Check file is not in
.gitignore(for shared configs)
Wrong Environment
Section titled “Wrong Environment”# Check current modeconsole.log(import.meta.env.MODE);
# Force specific modepnpm dev --mode stagingpnpm build --mode production