H
H
he he2017-03-05 16:14:06
Laravel
he he, 2017-03-05 16:14:06

Laravel broadcasting error?

I am writing a spa application in ui using laravel. Now there is a need to implement a real time component.
I use everything according to the standard (laravel-echo (js), events, shouldbrodacast (interface), and broadcastServiceProvider).
When sending a request to the controller where event(new...) I send another request:
site.ru/brodacasting/auth.
But it returns 403 with HttpException in RedisBroadcaster.php line 49:
It seems to have been suggested that it can be solved by passing the user token, but ...
How can I fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sungat Arynov, 2017-03-09
@Ginkidayo

if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
           ! $request->user()) {
            throw new HttpException(403);
        }

headers: {
            'X-CSRF-Token': $('meta[name=_token]').attr('content')
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question