31 lines
908 B
JavaScript
31 lines
908 B
JavaScript
|
|
import Echo from 'laravel-echo';
|
||
|
|
import Pusher from 'pusher-js';
|
||
|
|
|
||
|
|
window.Pusher = Pusher;
|
||
|
|
|
||
|
|
// Get CSRF token from meta tag
|
||
|
|
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||
|
|
window.Echo = new Echo({
|
||
|
|
broadcaster: 'reverb',
|
||
|
|
key: import.meta.env.VITE_REVERB_APP_KEY,
|
||
|
|
wsHost: import.meta.env.VITE_REVERB_HOST,
|
||
|
|
wsPort: import.meta.env.VITE_REVERB_PORT ?? 8080,
|
||
|
|
wssPort: import.meta.env.VITE_REVERB_PORT ?? 8080,
|
||
|
|
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'http') === 'https',
|
||
|
|
enabledTransports: ['ws', 'wss'],
|
||
|
|
|
||
|
|
authEndpoint: '/admin/broadcasting/auth',
|
||
|
|
|
||
|
|
|
||
|
|
// ⭐ MOST IMPORTANT ⭐
|
||
|
|
withCredentials: true,
|
||
|
|
|
||
|
|
auth: {
|
||
|
|
headers: {
|
||
|
|
'X-CSRF-TOKEN': csrfToken,
|
||
|
|
'Accept': 'application/json',
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('%c[ECHO] Initialized!', 'color: green; font-weight: bold;', window.Echo);
|