I upgraded my laravel 8 backend for SPA (vue.js, sanctum) to laravel 11, and post request /broadcasting/auth returns HTML response instead of json like { auth: "..." }
In previous version Broadcast::routes has been called from BroadcastServiceProvider, but now it is under the hood of laravel framework in ApplicationBuilder.php, and previously I've added sanctum middleware like this Broadcast::routes(['middleware' => ['auth:sanctum']]);
How should I do it in laravel 11?
I 've fixed broadcasting/auth by commenting out channels:... in app.php and putting in AppServiceProvider this
Broadcast::routes(['middleware' => ['auth:sanctum']]);
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('user.{toUserId}', function ($user, $toUserId) {
return $user->id == $toUserId;
});