Overview
CicloVital’s configuration system is built on Vite’s environment variable system and provides flexible settings for development and production environments.Environment Variables
CicloVital uses Vite’simport.meta.env for environment variable access. All public environment variables must be prefixed with VITE_.
Required Variables
Create a.env file in your project root:
.env
Variable Reference
Environment mode flag. Set to
'true' for production, 'false' for development.Used by authService to determine which API endpoint to use (src/services/authService.js:3).Local development API endpoint for user authentication services.Default:
http://localhost:8080/api/usersProduction API endpoint for user authentication services.Example:
https://api.ciclovital.com/api/usersEnvironment-Specific Files
Vite supports multiple environment files:API Configuration
The API configuration is centralized in service modules and automatically adapts based on environment variables.Authentication Service Configuration
src/services/authService.js:3-5
API Endpoints
User Service Endpoints:| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users | Create new user account |
| POST | /api/users/login | Authenticate user credentials |
The base URL is configured via environment variables and automatically prefixed to all endpoints.
Extending API Configuration
To add new service configurations, follow the same pattern:src/services/exampleService.js
.env:
.env
Vite Configuration
The Vite configuration provides build settings and development server options.Configuration File
vite.config.js
Configuration Options
Vite plugins to enable during build and development.Uses
@vitejs/plugin-react for Fast Refresh and JSX transformation.Global constant replacements during build.Defines
global as an empty object for Node.js package compatibility.Development server host binding.Binds to all network interfaces, allowing access from other devices on your network.
Development Server
When you runnpm run dev, Vite starts a development server with:
- Hot Module Replacement (HMR) - Instant updates without full page reload
- Fast Refresh - Preserves React component state during updates
- Network Access - Accessible from other devices via your local IP
- HTTPS Support - Can be enabled with additional configuration
Build Configuration
For production builds:- Bundle all source code using Rollup
- Optimize assets and dependencies
- Tree-shake unused code
- Minify JavaScript and CSS
- Output to
dist/directory
Preview Production Build
Test the production build locally:dist/ folder at http://localhost:4173/.
Additional Configuration
Capacitor Configuration (Mobile)
CicloVital includes Capacitor for mobile deployment:package.json
capacitor.config.json:
capacitor.config.json
ESLint Configuration
CicloVital uses ESLint for code quality:eslint.config.js
Axios Configuration
For advanced Axios configuration, create an instance:src/utils/axios.js
Environment Examples
Development Setup
.env.development
Production Setup
.env.production
Staging Setup
.env.staging
TypeScript Configuration (Optional)
For type-safe environment variables, createenv.d.ts:
env.d.ts
Troubleshooting
Environment variables not updating
Environment variables not updating
Restart the development server after changing
.env files:API calls failing in production
API calls failing in production
Verify that:
VITE_PRODis set to'true'(string, not boolean)- Production API URL is correct and accessible
- CORS is properly configured on the backend
Cannot access dev server from other devices
Cannot access dev server from other devices
Ensure
host: '0.0.0.0' is set in vite.config.js:8 and check your firewall settings.Find your network URL:Build fails with global is not defined
Build fails with global is not defined
This is handled by the
define: { global: {} } configuration. If you still see this error, ensure your vite.config.js is properly formatted.Best Practices
Use environment files
Separate configurations for dev, staging, and production environments
Never hardcode URLs
Always use environment variables for API endpoints and external services
Validate on startup
Check required environment variables exist before initializing services
Document all variables
Maintain a list of required environment variables with descriptions
Next Steps
Services API
Explore the complete API documentation for services
Hooks API
Learn about custom React hooks
Components Architecture
Discover component architecture and patterns
Mobile Setup
Set up the Android mobile application
