javascript - Laravel Echo not using Auth Headers - Stack Overflow

I update the header like this:window.setAuthToken = (token) => {window.Echo.options.auth.headers.Aut

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);
    });

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);
    });
Share Improve this question edited Dec 8, 2017 at 22:46 Fredrik asked Dec 8, 2017 at 22:36 FredrikFredrik 3,3028 gold badges36 silver badges72 bronze badges 2
  • Please post the code where you're firing the request – Paras Commented Dec 8, 2017 at 22:43
  • I edited my question with the code. Do you need more than that? – Fredrik Commented Dec 8, 2017 at 22:47
Add a ment  | 

2 Answers 2

Reset to default 3

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

This works for me.

window.Echo.connector.options.auth.headers.Authorization = "Bearer token";

"laravel-echo": "^1.15.3",

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745320157a4622407.html

相关推荐

  • javascript - Laravel Echo not using Auth Headers - Stack Overflow

    I update the header like this:window.setAuthToken = (token) => {window.Echo.options.auth.headers.Aut

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信