4.2 KiB
Executable File
4.2 KiB
Executable File
Environment Configuration Guide
Overview
All hardcoded IP addresses and domains have been moved to environment variables for easier configuration across different environments.
Quick Start
-
Copy the example file:
cp env.example .env -
Edit
.envwith your values:# For local development VITE_API_URL=http://localhost:8000 VITE_DEV_HOST=192.168.200.10 # For production VITE_API_URL=https://mc.exbytestudios.com VITE_PROD_DOMAIN=mc.exbytestudios.com -
Start development server:
npm run dev
Environment Variables
API Configuration
VITE_API_URL- Base URL for API endpoints (default:https://mc.exbytestudios.com)- Development:
http://localhost:8000 - Production:
https://mc.exbytestudios.com
- Development:
Domain Configuration
VITE_PROD_DOMAIN- Production domain (default:mc.exbytestudios.com)VITE_BACKUP_DOMAIN- Backup domain (default:backup.mc.exbytestudios.com)VITE_TEST_DOMAIN- Test domain (default:test.exbytestudios.com)
Development Server Configuration
VITE_DEV_HOST- Vite dev server host (default:192.168.200.10)VITE_DEV_PORT- Vite dev server port (default:5173)VITE_DEV_ALLOWED_HOST- Allowed host for HMR (default:test.exbytestudios.com)
Security Settings
VITE_ENABLE_CERTIFICATE_PINNING- Enable/disable certificate pinning (default:true)- Set to
falsein development - Set to
truein production
- Set to
VITE_CERTIFICATE_PINNING_FALLBACK- Enable fallback for certificate pinning (default:true)
Development Settings
VITE_DEBUG_MODE- Enable debug mode (default:false)VITE_LOG_LEVEL- Logging level:debug,info,warn,error(default:info)
Files Using Environment Variables
Configuration Files
vite.config.ts- UsesVITE_DEV_HOST,VITE_DEV_PORT,VITE_DEV_ALLOWED_HOSTsrc/renderer/config/api.ts- UsesVITE_API_URL
Service Files
src/renderer/services/CertificatePinning.ts- UsesVITE_PROD_DOMAIN,VITE_BACKUP_DOMAINsrc/renderer/utils/csp.ts- UsesVITE_PROD_DOMAINsrc/renderer/mocks/mockMachines.ts- UsesVITE_DEV_HOST
Static Configuration Files (Manual Update Required)
csp-config.json- Update production domains manually to match.envindex.html- CSP meta tag uses hardcoded values (acceptable for development)
Development vs Production
Development (.env.development)
VITE_API_URL=http://localhost:8000
VITE_DEV_HOST=192.168.200.10
VITE_ENABLE_CERTIFICATE_PINNING=false
VITE_DEBUG_MODE=true
VITE_LOG_LEVEL=debug
Production (.env.production)
VITE_API_URL=https://mc.exbytestudios.com
VITE_PROD_DOMAIN=mc.exbytestudios.com
VITE_ENABLE_CERTIFICATE_PINNING=true
VITE_DEBUG_MODE=false
VITE_LOG_LEVEL=info
Migration from Hardcoded Values
All instances of hardcoded IP (192.168.200.10) and domains (*.exbytestudios.com) have been replaced with environment variables:
Before
const API_URL = 'https://mc.exbytestudios.com';
host: '192.168.200.10'
After
const API_URL = import.meta.env.VITE_API_URL || 'https://mc.exbytestudios.com';
host: import.meta.env.VITE_DEV_HOST || '192.168.200.10'
Security Notes
- Never commit
.envfiles to git - They are in.gitignoreby default - Use different values for each environment - Development, Testing, Production
- Enable certificate pinning in production - Set
VITE_ENABLE_CERTIFICATE_PINNING=true - Update
csp-config.json- When changing production domains, update CSP config manually
Troubleshooting
API connection fails
- Check
VITE_API_URLmatches your API server - Verify API server is running
- Check network connectivity
HMR (Hot Module Replacement) not working
- Verify
VITE_DEV_HOSTis accessible - Check
VITE_DEV_ALLOWED_HOSTmatches your access domain - Ensure WebSocket connections are allowed
Certificate pinning errors
- Disable in development:
VITE_ENABLE_CERTIFICATE_PINNING=false - Verify certificate fingerprints in production
- Check
VITE_PROD_DOMAINmatches actual certificate domain