import Echo from 'laravel-echo'; import Pusher from 'pusher-js'; // Reverb (Pusher protocol), proxied same-origin through nginx (/app, /apps). // The browser connects to the page's own host/port — works on localhost and over the LAN // with no separate WS port and no host mismatch. Every channel is PRIVATE (/broadcasting/auth). const loc = window.location; const isHttps = loc.protocol === 'https:'; const port = loc.port ? Number(loc.port) : (isHttps ? 443 : 80); window.Pusher = Pusher; window.Echo = new Echo({ broadcaster: 'reverb', key: import.meta.env.VITE_REVERB_APP_KEY, wsHost: loc.hostname, wsPort: port, wssPort: port, forceTLS: isHttps, enabledTransports: ['ws', 'wss'], });