Laravel Echo不使用Auth Headers [英] Laravel Echo not using Auth Headers

查看:50
本文介绍了Laravel Echo不使用Auth Headers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样更新标题:

window.setAuthToken = (token) => {
    window.Echo.options.auth.headers.Authorization = 'Bearer ' + token;
}

令牌在Laravel回显头中设置,如下所示:

The token is set in the Laravel Echo Headers, as seen here:

但是它未使用,如下所示:

为什么Laravel Echo不使用Auth Headers?

Why is Laravel Echo not using Auth Headers?

修改:我还尝试过动态更新端点,例如 window.Echo.connector.options.authEndpoint =''; ,该端点在选项中设置但未被请求使用.

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';

这篇关于Laravel Echo不使用Auth Headers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆