const resolveChatSocketUrl = (raw?: string): string => { if (!raw) return 'http://localhost:3000' const trimmed = raw.replace(/\/+$/, '') if (trimmed.endsWith('/api/v1')) { return trimmed.slice(0, -'/api/v1'.length) } return trimmed } export const CHAT_SOCKET_URL = resolveChatSocketUrl(process.env.NEXT_PUBLIC_API_URL) export const CHAT_SOCKET_NAMESPACE = '/chat'