Skip to content

Environment Variables

This guide covers all environment variables used in IONFLOW Frontend.

Environment variables are managed using Vite’s built-in support. All variables must be prefixed with VITE_ to be exposed to the application.

FilePurposeGit Tracked
.envDefault valuesYes
.env.localLocal overridesNo
.env.developmentDevelopment modeYes
.env.productionProduction modeYes
.env.[mode].localMode-specific localNo
Terminal window
# Backend API URL
VITE_API_URL=http://localhost:8000/api
# API Version
VITE_API_VERSION=v1
# Gateway API URL
VITE_GATEWAY_URL=http://localhost:8001
Terminal window
# Keycloak Server URL
VITE_KEYCLOAK_URL=http://localhost:8080
# Keycloak Realm
VITE_KEYCLOAK_REALM=ionflow
# Keycloak Client ID
VITE_KEYCLOAK_CLIENT_ID=ionflow-frontend
# Enable Keycloak (true/false)
VITE_KEYCLOAK_ENABLED=true
Terminal window
# Enable Vue DevTools
VITE_ENABLE_DEV_TOOLS=true
# Enable debug mode
VITE_DEBUG_MODE=false
# Enable mock API
VITE_MOCK_API=false
Terminal window
# Application title
VITE_APP_TITLE=IONFLOW
# Default language (en/es)
VITE_DEFAULT_LOCALE=en
# Items per page default
VITE_DEFAULT_PAGE_SIZE=20
// Direct access
const apiUrl = import.meta.env.VITE_API_URL;
// With type safety
const config = {
apiUrl: import.meta.env.VITE_API_URL as string,
isDebug: import.meta.env.VITE_DEBUG_MODE === 'true',
};

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;
}
.env.development
VITE_API_URL=http://localhost:8000/api
VITE_KEYCLOAK_URL=http://localhost:8080
VITE_ENABLE_DEV_TOOLS=true
VITE_DEBUG_MODE=true
.env.staging
VITE_API_URL=https://staging-api.ionflow.com/api
VITE_KEYCLOAK_URL=https://staging-auth.ionflow.com
VITE_ENABLE_DEV_TOOLS=true
VITE_DEBUG_MODE=false
.env.production
VITE_API_URL=https://api.ionflow.com/api
VITE_KEYCLOAK_URL=https://auth.ionflow.com
VITE_ENABLE_DEV_TOOLS=false
VITE_DEBUG_MODE=false
  • API keys or secrets
  • Database credentials
  • Private encryption keys
  • Internal service URLs
  • Public API endpoints
  • Feature flags
  • UI configuration
  • Public Keycloak settings

Environment variables are replaced at build time. This means:

// ✅ Works - variable is replaced
const url = import.meta.env.VITE_API_URL;
// ❌ Won't work - dynamic access
const key = 'VITE_API_URL';
const url = import.meta.env[key];

For Docker deployments, pass variables at runtime:

# Dockerfile
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
RUN pnpm build
Terminal window
# Build with variables
docker build --build-arg VITE_API_URL=https://api.example.com -t ionflow .
jobs:
build:
steps:
- name: Build
env:
VITE_API_URL: ${{ secrets.API_URL }}
VITE_KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
run: pnpm build
  1. Ensure prefix is VITE_
  2. Restart development server after changes
  3. Check file is not in .gitignore (for shared configs)
Terminal window
# Check current mode
console.log(import.meta.env.MODE);
# Force specific mode
pnpm dev --mode staging
pnpm build --mode production