tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.64k stars 509 forks source link

Laravel Sanctum Auth 403 #522

Closed mehmetcansahin closed 4 years ago

mehmetcansahin commented 4 years ago

Hello I'm trying to login to a channel with laravel echo.

I use Sanctum, I get 403 as the request response. Why do you think it might be?

var echo = new Echo({
  broadcaster: "socket.io",
  host: "localhost:6001",
  client: io,
  auth: {
    endpoint: '/broadcasting/auth',
    headers: {
      Authorization: "Bearer " + key,
      Referer: window.location.hostname,
    },
  },
});

Response; Status | 403

 {
"message": "",
"exception": "Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException",
"file": "/var/www/torrentvideo/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php",
"line": 81,
"trace": [
{
"file": "/var/www/torrentvideo/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php",
"line": 69,
"function": "verifyUserCanAccessChannel",
"class": "Illuminate\Broadcasting\Broadcasters\Broadcaster",
"type": "->"
}, 
...
mehmetcansahin commented 4 years ago

I realized that the cause of the problem is that I cannot see the channels originating from the api prefix I have changed. If you overwrite the web route with the api route, you need to define your channels under the api route.