Enhance backend configuration and error handling: Update CORS settings to allow dynamic origins, improve RabbitMQ connection handling in chat services, and adjust API server host configuration. Refactor environment variables for better flexibility and add fallback mechanisms for WebSocket and chat services. Update frontend environment files for consistent API and WebSocket URLs.
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
// Centralized config for YourChat protocol mapping and WS endpoint
|
||||
// Override via .env (VITE_* variables)
|
||||
import { getChatWsUrlFromEnv } from './appConfig.js';
|
||||
|
||||
const env = import.meta.env || {};
|
||||
|
||||
export const CHAT_WS_URL = env.VITE_CHAT_WS_URL
|
||||
|| (env.VITE_CHAT_WS_HOST || env.VITE_CHAT_WS_PORT
|
||||
? `ws://${env.VITE_CHAT_WS_HOST || 'localhost'}:${env.VITE_CHAT_WS_PORT || '1235'}`
|
||||
: (typeof window !== 'undefined' && window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + '/socket.io/');
|
||||
export const CHAT_WS_URL = getChatWsUrlFromEnv();
|
||||
|
||||
// Event/type keys
|
||||
export const CHAT_EVENT_KEY = env.VITE_CHAT_EVENT_KEY || 'type';
|
||||
|
||||
Reference in New Issue
Block a user