fix reverb from cross origin
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user