0
votes

i'm new to laravel broadcast events. i make a chat app with vuejs and laravel api backend. i set up laravel event broadcast to show realtime messages. In my vue app i add these configurations.

import Echo from "laravel-echo";
window.Pusher = require("pusher-js");

window.Echo = new Echo({
  authEndpoint: "http://quasarchat.test/api/auth/broadcasting/auth",
  auth: {
    headers: {
      Authorization: `Bearer ${store.state.AuthModule.token}`,
    },
  },
  broadcaster: "pusher",
  key: "myappkey",
  wsHost: "quasarchat.test",
  encrypted: false,
  wsPort: 6001,
  disableStats: false,
  enabledTransports: ["ws", "wss"],
});

and in my backend i configure laravel websockets. i make authentication with jwt auth. my laravel api routes looks like this.

Route::group(['prefix' => 'auth', 'namespace' => 'Auth'], function () {
    Route::post('signin', 'SignInController')->name('login');
    Route::post('signout', 'SignOutController');
    Route::get('me', 'MeController');
});

and in my app/providers BroadcastService looks like below.

public function boot()
{
  Broadcast::routes([
  'middleware' => 'auth:api',
  'prefix' => 'api/auth/'
   ]);
   require base_path('routes/channels.php');
}

but i have a error occured when app loads with pusher.

GET http://quasarchat.test/api/auth/signin 405 (Method Not Allowed)

i declared my signin method in post. but this shows me a get request to signin. i think this occurs with broadcast routes. how can i fix this. anyone can help me?

1

1 Answers

0
votes

You need to uncomment the BroadcastServiceProvider class in config/app.php.