sid heart
sid heart

Reputation: 1149

CSRF token mismatch larave-echo-server with nuxt

i have realtime application in nuxt and laravel with laravel-echo-server

when i use this

window.Echo.channel(`laravel_database_test-channel`).listen(
        "TestEvent",
        e => {
          console.log(e);
        }
      );

everything works fine

but when i try in private channel like this

window.Echo.private(`laravel_database_test-channel`).listen(
        "TestEvent",
        e => {
          console.log(e);
        }
      );

getting error "message": "CSRF token mismatch."

here is full screenshot

enter code here

Upvotes: 0

Views: 1391

Answers (1)

sid heart
sid heart

Reputation: 1149

goto App\Providers\BroadcastServiceProvider modify this

Broadcast::routes();

to

Broadcast::routes(['prefix' => 'api', 'middleware' => ['auth:api']]);

and in your laravel-echo-server.json

edit this

"authEndpoint": "/api/broadcasting/auth",

this helps me and working fine

Upvotes: 4

Related Questions