title: How to implement laravel-echo client into Vue project
body: <p>I'm developing an application with <strong>Vuetify</strong> (Vue.js) as front-end that communicates with api to <strong>laravel</strong> backend server.</p>
  
  <p>I'm trying to make a system of notifications with <strong>laravel-echo-server</strong> working with <strong>socket.io</strong>. And using laravel-echo into client too.</p>
  
  <p>The code that I uses into a component of client to test if connection works is:</p>
  
  <pre><code>// Needed by laravel-echo
  window.io = require('socket.io-client')
  
  let token = this.$store.getters.token
  
  let echo = new Echo({
    broadcaster: 'socket.io',
    host: 'http://localhost:6001',
    auth: {
      headers: {
        authorization: 'Bearer ' + token,
        'X-CSRF-TOKEN': 'too_long_csrf_token_hardcoded'
      }
    }
  })
  
  echo.private('Prova').listen('Prova', () =&gt; {
    console.log('IT WORKS!')
  })
  </code></pre>
  
  <p>This is the code of <code>laravel-echo-server.json</code></p>
  
  <pre><code>{
      "authHost": "http://gac-backend.test",
      "authEndpoint": "/broadcasting/auth",
      "clients": [],
      "database": "redis",
      "databaseConfig": {
          "redis": {},
          "sqlite": {
              "databasePath": "/database/laravel-echo-server.sqlite"
          }
      },
      "devMode": true,
      "host": null,
      "port": "6001",
      "protocol": "http",
      "socketio": {},
      "sslCertPath": "",
      "sslKeyPath": "",
      "sslCertChainPath": "",
      "sslPassphrase": "",
      "apiOriginAllow": {
          "allowCors": false,
          "allowOrigin": "",
          "allowMethods": "",
          "allowHeaders": ""
      }
  }
  </code></pre>
  
  <p>I tried to modify <strong>apiOriginsAllow</strong> without success.
  The event is dispatched, I can see it into <strong>laravel-echo-server</strong> logs:</p>
  
  <pre><code>Channel: Prova
  Event: App\Events\Prova
  </code></pre>
  
  <p>But after that, when I access into a component of the client that contains the connection code I can see in laravel-echo-server logs long error trace and the next error:</p>
  
  <pre><code>The client cannot be authenticated, got HTTP status 419
  </code></pre>
  
  <p>As you can see, I specified csrf token and authorization token into the headers of laravel echo client. But it doesn't work.</p>
  
  <p>This is the code of <code>routes/channels.php</code>:</p>
  
  <pre><code>Broadcast::channel('Prova', function ($user) {
      return true;
  });
  </code></pre>
  
  <p>I only want to listen an event, it doesn't important if it is private or public because when it works, I want to put it into service worker. Then, I suppose that is better if it is public.</p>
  
  <ul>
  <li><strong>How can I use laravel echo client out of laravel project?</strong></li>
  <li><strong>Will be a problem if I make private event and try to listen it into a service worker?</strong></li>
  </ul>