Refactor API configuration and improve WebSocket handling in frontend and backend

This commit is contained in:
M1ngdaXie
2026-02-03 17:25:11 -08:00
parent 35c4aa2580
commit 70a406c73c
14 changed files with 335 additions and 131 deletions

View File

@@ -0,0 +1,24 @@
interface Config {
apiUrl: string;
wsUrl: string;
environment: 'development' | 'production';
}
function loadConfig(): Config {
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080/api';
const wsUrl = import.meta.env.VITE_WS_URL || 'ws://localhost:8080/ws';
const environment = import.meta.env.MODE === 'production' ? 'production' : 'development';
return {
apiUrl,
wsUrl,
environment,
};
}
export const config = loadConfig();
// Convenience exports
export const API_BASE_URL = config.apiUrl;
export const WS_URL = config.wsUrl;
export const isProduction = config.environment === 'production';