chatterbox-ui/frontend/js/config.js

36 lines
1.3 KiB
JavaScript

// Frontend Configuration
// This file handles environment variable configuration for the frontend
// Get environment variables (these would be injected by a build tool like Vite)
// For now, we'll use defaults that can be overridden
const getEnvVar = (name, defaultValue) => {
// In a real Vite setup, this would be import.meta.env[name]
// For now, we'll check if there's a global config object or use defaults
if (typeof window !== 'undefined' && window.APP_CONFIG && window.APP_CONFIG[name]) {
return window.APP_CONFIG[name];
}
return defaultValue;
};
// API Configuration
export const API_BASE_URL = getEnvVar('VITE_API_BASE_URL', 'http://localhost:8000');
export const API_BASE_URL_WITH_PREFIX = getEnvVar('VITE_API_BASE_URL_WITH_PREFIX', 'http://localhost:8000/api');
// For file serving (same as API_BASE_URL since files are served from the same server)
export const API_BASE_URL_FOR_FILES = API_BASE_URL;
// Development server configuration
export const DEV_SERVER_PORT = getEnvVar('VITE_DEV_SERVER_PORT', '8001');
export const DEV_SERVER_HOST = getEnvVar('VITE_DEV_SERVER_HOST', '127.0.0.1');
// Export all config as a single object for convenience
export const CONFIG = {
API_BASE_URL,
API_BASE_URL_WITH_PREFIX,
API_BASE_URL_FOR_FILES,
DEV_SERVER_PORT,
DEV_SERVER_HOST
};
export default CONFIG;