vendredi 10 avril 2020

Laravel private channel authorization not working

I am learning pusher to use it with Laravel, I am trying to subscribe to private channel using Laravel-echo as follow:

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({

    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: true
});

var channel = window.Echo.private('roomr');

and per Laravel documentations I have to set authorization in channel.php file so in I wrote in it:

Broadcast::channel('roomr', function ($user) {
    logger('hit authorize roomr');
    return true;
});

please note that I used logger('hit authorize roomr'); to know if my function is being called, but, when I check the log file it is empty which means that this function is not being called.

using developer tools in google chrome I see there is a post request sent to http://127.0.0.1:8000/broadcasting/auth which return response 200, so, I do not think the authentication is the problem.

what else I can do? please help me to solve this probem



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire