Laravel - Broadcasting - Customizing The Authorization Request

You can customize how Laravel Echo performs authorization requests by providing a custom authorizer when initializing Echo:

    
    window.Echo = new Echo({
        // ...
        authorizer: (channel, options) => {
            return {
                authorize: (socketId, callback) => {
                    axios.post('/api/broadcasting/auth', {
                        socket_id: socketId,
                        channel_name: channel.name
                    })
                    .then(response => {
                        callback(false, response.data);
                    })
                    .catch(error => {
                        callback(true, error);
                    });
                }
            };
        },
    })