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:
@@ -35,7 +35,7 @@ export function setupWebSocket(server) {
|
||||
|
||||
export function getIo() {
|
||||
if (!io) {
|
||||
throw new Error('Socket.io ist nicht initialisiert!');
|
||||
return null;
|
||||
}
|
||||
return io;
|
||||
}
|
||||
@@ -46,6 +46,10 @@ export function getUserSockets() {
|
||||
|
||||
export async function notifyUser(recipientHashedUserId, event, data) {
|
||||
const io = getIo();
|
||||
if (!io) {
|
||||
if (DEBUG_SOCKETS) console.warn('[socket.io] notifyUser übersprungen: Socket.io nicht initialisiert');
|
||||
return;
|
||||
}
|
||||
const userSockets = getUserSockets();
|
||||
try {
|
||||
const recipientUser = await baseService.getUserByHashedId(recipientHashedUserId);
|
||||
@@ -70,6 +74,10 @@ export async function notifyUser(recipientHashedUserId, event, data) {
|
||||
|
||||
export async function notifyAllUsers(event, data) {
|
||||
const io = getIo();
|
||||
if (!io) {
|
||||
if (DEBUG_SOCKETS) console.warn('[socket.io] notifyAllUsers übersprungen: Socket.io nicht initialisiert');
|
||||
return;
|
||||
}
|
||||
const userSockets = getUserSockets();
|
||||
|
||||
try {
|
||||
@@ -80,4 +88,4 @@ export async function notifyAllUsers(event, data) {
|
||||
} catch (err) {
|
||||
console.error('Fehler beim Senden der Benachrichtigung an alle Benutzer:', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user