2

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: Console result

But it is not used, as seen here: Headers

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);
    });
2
  • Please post the code where you're firing the request Commented Dec 8, 2017 at 22:43
  • I edited my question with the code. Do you need more than that? Commented Dec 8, 2017 at 22:47

2 Answers 2

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';
Sign up to request clarification or add additional context in comments.

1 Comment

this gives [Vue warn]: Error in callback for watcher "isAuthenticated": "TypeError: Cannot read property 'pusher' of undefined"
2

This works for me.

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

"laravel-echo": "^1.15.3",

1 Comment

This one solved my problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.