fix reverb from cross origin

This commit is contained in:
2026-02-24 15:40:35 +01:00
parent c85490e1c6
commit ad770c1055
+23
View File
@@ -14,8 +14,31 @@ export default function initEcho() {
encrypted: import.meta.env.VITE_ENCRYPTED === 'true', encrypted: import.meta.env.VITE_ENCRYPTED === 'true',
cluster: import.meta.env.VITE_CLUSTER, cluster: import.meta.env.VITE_CLUSTER,
enabledTransports: ['ws', 'wss'], enabledTransports: ['ws', 'wss'],
authorizer: (channel) => {
return {
authorize: (socketId, callback) => {
fetch(`${import.meta.env.VITE_API_URL}/broadcasting/auth`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
body: JSON.stringify({
socket_id: socketId,
channel_name: channel.name,
}),
})
.then(res => res.json())
.then(data => callback(null, data))
.catch(err => callback(err, null));
},
};
},
}); });
window.Echo = echoInstance; window.Echo = echoInstance;
return echoInstance; return echoInstance;
} }