title: laravel-echo The POST method is not supported for this route
body: <p>so I'm trying to connect to a private channel using Laravel Echo. I am able to connect to a public channel but I'm getting issues authenticating a (logged in with correct Bearer token) private channel - getting the following error from <code>laravel-echo-server start</code></p>
  
  <pre><code>L A R A V E L  E C H O  S E R V E R
  
  version 1.6.2
  
  ⚠ Starting server in DEV mode...
  
  ✔  Running at localhost on port 6001
  ✔  Channels are ready.
  ✔  Listening for http events...
  ✔  Listening for redis events...
  
  Server ready!
  
  [10:58:39 PM] - Preparing authentication request to: https://example.co.uk
  [10:58:39 PM] - Sending auth request to: https://example.co.uk/api/broadcasting/auth/
  
  ⚠ [10:58:39 PM] - K1cJaXs7jWMBNpF9AAAA could not be authenticated to private-sonect_database_user.2
  {"errors":{"message":"The POST method is not supported for this route. Supported methods: GET, HEAD."}}
  Client can not be authenticated, got HTTP status 401
  
  </code></pre>
  
  <p>I'm confused by the error <code>POST method is not supported</code> because all POST, PUT, PATCH, and DELETE all work in my Laravel project. Furthermore, I am able to hit <code>https://example.co.uk/api/broadcasting/auth/</code> using Postman with a POST request.</p>
  
  <p>Here's a sample of <code>php artisan route:list</code></p>
  
  <pre><code>| Domain | Method        | URI                                           | Name                              | Action                                                                    | Middleware   |
  |        | GET|POST|HEAD | api/broadcasting/auth                         |                                   | Illuminate\Broadcasting\BroadcastController@authenticate                  | auth:api     |
  </code></pre>
  
  <p>PlayerEvent.php</p>
  
  <pre><code>namespace App\Events;
  
  use App\Models\User;
  use Illuminate\Broadcasting\Channel;
  use Illuminate\Broadcasting\InteractsWithSockets;
  use Illuminate\Broadcasting\PresenceChannel;
  use Illuminate\Broadcasting\PrivateChannel;
  use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
  use Illuminate\Foundation\Events\Dispatchable;
  use Illuminate\Queue\SerializesModels;
  
  class PlayerEvent implements ShouldBroadcast
  {
      use Dispatchable, InteractsWithSockets, SerializesModels;
  
      public $user;
  
      /**
       * Create a new event instance.
       *
       * @param User $user
       * @return void
       */
      public function __construct(User $user)
      {
          $this-&gt;user = $user;
      }
  
      /**
       * Get the channels the event should broadcast on.
       *
       * @return \Illuminate\Broadcasting\Channel|array
       */
      public function broadcastOn()
      {
          return new PrivateChannel('user.' . $this-&gt;user-&gt;id);
      }
  
      /**
       * The event's broadcast name.
       *
       * @return string
       */
      public function broadcastAs()
      {
          return 'PlayerEvent';
      }
  
      /**
       * The event's broadcast name.
       *
       * @return array
       */
      public function broadcastWith()
      {
          return ['message' =&gt; 'Hello world'];
      }
  
  }
  </code></pre>
  
  <p>BroadcaseServiceProvider.php</p>
  
  <pre><code>    public function boot()
      {
          Broadcast::routes(["prefix" =&gt; "api", "middleware" =&gt; "auth:api"]);
  
          require base_path('routes/channels.php');
      }
  </code></pre>
  
  <p>config/app.php</p>
  
  <pre><code>
          /*
           * Application Service Providers...
           */
          App\Providers\AppServiceProvider::class,
          App\Providers\AuthServiceProvider::class,
          App\Providers\BroadcastServiceProvider::class,
          App\Providers\EventServiceProvider::class,
          App\Providers\RouteServiceProvider::class,
  </code></pre>
  
  <p>routes/channel.php</p>
  
  <pre><code>
  Broadcast::channel('user.{user}', function ($user) {
      return true;
  });
  </code></pre>
  
  <p>laravel-echo-server.json</p>
  
  <pre><code>{
      "authHost": "https://example.co.uk",
      "authEndpoint": "/api/broadcasting/auth/",
      "clients": [
          {
              "appId": "4cb2c72910d85007",
              "key": "d3af62258887434b9900b89a937cb7f7"
          }
      ],
      "database": "redis",
      "databaseConfig": {
          "redis": {},
          "sqlite": {
              "databasePath": "/database/laravel-echo-server.sqlite"
          },
          "publishPresence": true
      },
      "devMode": true,
      "host": null,
      "port": "6001",
      "protocol": "https",
      "socketio": {},
      "secureOptions": 67108864,
      "sslCertPath": "/var/www/example.co.uk/letsencrypt/live/example.co.uk/fullchain.pem",
      "sslKeyPath": "/var/www/example.co.uk/letsencrypt/live/example.co.uk/privkey.pem",
      "sslCertChainPath": "",
      "sslPassphrase": "",
      "subscribers": {
          "http": true,
          "redis": true
      },
      "apiOriginAllow": {
          "allowCors": true,
          "allowOrigin": "http://localhost:4200/",
          "allowMethods": "GET, POST, PUT, PATCH, DELETE",
          "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
      }
  }
  </code></pre>
  
  <p>I'm using angular on the front end </p>
  
  <p>echo.service.ts</p>
  
  <pre><code>import {Injectable} from "@angular/core";
  import {environment} from "../../../environments/environment";
  import Echo from "laravel-echo";
  import {UserModel} from "../models/user.model";
  import * as io from "socket.io-client";
  
  @Injectable({
      providedIn: 'root'
  })
  export class EchoService {
  
      public echo: Echo;
  
      constructor() {
          window['io'] = io;
          this.echo = window['Echo'] = new Echo({
              broadcaster: 'socket.io',
              host: environment.websocketUrl, // https://example.co.uk:6001
              auth: {
                  headers: {
                      Authorization: `Bearer ${localStorage.getItem('token')}`
                  }
              }
          });
      }
  
      /** privateChannel('user', 'PlayerEvent', this.user); Called from elsewhere */
      privateChannel(channelName: string, eventName: string, user: UserModel) {
          console.log('privateChannel');
          this.echo.private( environment.broadcastChannelPrefix + channelName + '.' + user.id)
              .listen('.' + eventName, data =&gt; {
                  console.log(data);
              });
      }
  }
  </code></pre>
  
  <p>Laravel: 7.12.0<br>
  laravel-echo: ^1.8.0<br>
  socket.io-client: ^2.3.0<br>
  Angular: 9.1.9  </p>