I have a created a notification system with all setup and its working fine when i send notification to pusher. But when I try to listen on private channel I get error.
Here is my bootstrap.js file laravel-echo code
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
let token = document.head.querySelector('meta[name="csrf-token"]').content;
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: true,
auth: {
headers: {
'X-CSRF-Token': token
}
}
});
Here is my meta tag content of main html
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="user-id" content="{{Auth::check() ? Auth::user()->api_token:''}}">
Here is the code to listen in app.js
let userId = document.head.querySelector('meta[name="user-id"]').content;
Echo.private('App.User.' + userId)
.notification((notification) => {
console.log(notification.type);
});
Here is the error i am getting on console
POST http://localhost:3000/broadcasting/auth 419 (unknown status)
Thanks in advance