1

I have some issues about to connect to broadcasting from React

I sure don't have any error on my code, this is my code

on my broadcast.php on config folder

     'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'encrypted' => true,
                'host' => '192.168.0.114',
                'port' => 6001,
                'scheme' => 'http'
            ],
        ],

and on my api.php on route folder i am adding

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

on .env file

PUSHER_APP_ID=osamah
PUSHER_APP_KEY=osamah
PUSHER_APP_SECRET=osamah
PUSHER_APP_CLUSTER=mt1

on channel.php

Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

on my react listen

 const echo = new Echo({
        broadcaster: 'pusher',
        key: 'osamah',
        cluster: 'mt1',
        wsHost: '192.168.0.114',
        wsPort: 6001,
        forceTLS: false,
        disableStats: true,
        authEndpoint: "http://192.168.0.114/api/broadcasting/auth",
        auth: {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer 1542|3hVrlJ3A968IeZ23kejqTp8CJ9p4RCkcj66gRK4z'
            },
        }

    });

    echo.connector.pusher.connection.bind('connected', () => {
        console.log('connected');
        axios.get(`http://192.168.0.114/api/count`, {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer 1542|3hVrlJ3A968IeZ23kejqTp8CJ9p4RCkcj66gRK4z'
            },
        })
            .then(res => {
                console.log(res);
            })
    });

    echo.private('App.Models.User.393').notification((e)=>console.log(e.user));
dbf
  • 3,278
  • 1
  • 24
  • 34
Osamah
  • 11
  • 2
  • 2
    As I remember, **419 is not a standard HTTP status code**; check your error logs and check `Authorization` is correct – Abdulla Nilam Jan 30 '23 at 09:28
  • 1
    its working on anther project i created but when copy it to my main project show this status <<< how i can check error log ? – Osamah Jan 30 '23 at 09:33
  • 1
    `419` often means a missing CSRF token. Make sure your API routes are in `api.php`, and that `VerifyCsrfToken` is not in your api middleware group in Kernel.php – aynber Feb 02 '23 at 16:49

0 Answers0