Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #309
    jacob_smith
    Participant

    I am getting an error “broadcasting/auth 404 (Not Found)” on my browser console. I am developing a chat system using laravel websockets and laravel echo.

    window.Echo = new Echo({
    broadcaster: ‘pusher’,
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    wsHost: window.location.hostname,
    cluster:import.meta.env.VITE_PUSHER_APP_CLUSTER,
    wsPort: 6001,
    ecrypted: true,
    forceTLS: false,
    disableStats: true,
    });

    I believe the error is in Laravel Echo configuration because the error is getting displayed on the browser.

    I already uncommented App\Providers\BroadcastServiceProvider and checked that Broadcast::routes() generated the broadcasting/auth route by doing php artisan route:list and therefore the route is in the list.

    I’m not sure why broadcasting/auth is getting a 404 Not Found

    • This topic was modified 1 year, 2 months ago by jacob_smith.
    #321

    The Broadcast::routes method will automatically place its routes within the web middleware group so that should work. In some weird cases you may have to hardcode the route in the Laravel Echo Configuration as follows:

    window.Echo = new Echo({
    broadcaster: ‘pusher’,
    // …
    authEndpoint: ‘/custom/endpoint/auth’
    });

    If you are in local development you can write authEndpoint as follows:

    window.Echo = new Echo({
    broadcaster: ‘pusher’,
    // …
    authEndpoint: ‘http://localhost/YourAppName/public/broadcasting/auth’
    });

    This only matters if you need authorizing request into the route which means you are probably using a private channel from your request. If there is no need for private channel just switch to public channel.

    Please check this documentation from Laravel on Broadcasting under Authorizing Channels

    #322
    jacob_smith
    Participant

    Thank you it works.

    https://laravel.com/docs/10.x/broadcasting#defining-authorization-routes

    • This reply was modified 1 year, 2 months ago by jacob_smith.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.