Add Container field
This commit is contained in:
31
resources/js/echo.js
Normal file
31
resources/js/echo.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user