[Vuejs]-Laravel Echo not receiving puher events

0πŸ‘

In MessageSent event do this

public function broadcastOn()
{
    Broadcast::routes(['middleware' => ['auth:api']]);
    return new PrivateChannel('chat');
}

And in BroadcastServiceProvider add the following line:

Broadcast::routes(['middleware' => ['auth:api']]);

0πŸ‘

I have solved this by putting the below code from bootstrap.js to app.js. So, in my app.js –

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: true,
});

But I don’t know why the same code is not working in bootstrap.js

Leave a comment