I update the header like this:
window.setAuthToken = (token) => {
window.Echo.options.auth.headers.Authorization = 'Bearer ' + token;
}
The token is set in the Laravel Echo Headers, as seen here:
But it is not used, as seen here:
Why is Laravel Echo not using Auth Headers?
Edit:
I also tried dynamically update the endpoint like window.Echo.connector.options.authEndpoint = '';
, and it is set in the options but not used by the request.
This is how I connect to the channel.
Echo.private('app.User.' + data.user_id)
.notification((notification) => {
dispatch('handle', notification);
});
It seems like the way to do it was pretty close to what I was trying. Solution was found here.
Echo.connector.pusher.config.auth.headers['Authorization'] = 'Bearer token';