http://localhost:8000/broadcasting/auth 404 (Not Found)
Asked Answered
H

7

36

I am trying to make my app app connect to pusher on a private channel.

But I am getting the following error:

pusher.js?b3eb:593 POST http://localhost:8000/broadcasting/auth 404 (Not Found)

What maybe the cause of the error and how to resolve it.

Headmistress answered 17/1, 2017 at 18:29 Comment(4)
You need to set up an HTTP server running on localhost:8000 which can handle requests to /broadcasting/auth. The Pusher server libraries provide helper functions for handling these requests.Bik
Have you resolved the isssue? I have both BroadcastServiceProvider classes uncommented in th config/app. Have cleared compiled services , config cache and route cache. Still doesn't work.Dynamiter
@Dynamiter use public channel and use auth middleware on itHeadmistress
I had the same error and got stuck on it for about 2 hours. Turns out it was my local host i set up a virtual host in my xammp vhosts file and the error disappeared.Heimdall
L
119

Look in config/app.php if you have uncommented

App\Providers\BroadcastServiceProvider::class,

Lesleylesli answered 19/1, 2017 at 13:50 Comment(3)
Saved my time. ThanksBorchardt
MC laravel doc creator never mentioned this.Compartmentalize
Saved my time too !Heron
A
24

There are two Service Providers with Same name but different namespace in config/app.php

Illuminate\Broadcasting\BroadcastServiceProvider::class,

App\Providers\BroadcastServiceProvider::class,

So uncomment both of them. It will work.

Alyciaalyda answered 10/4, 2017 at 7:14 Comment(0)
S
20

Hope your base url is wrong try to hardcore your base url like below

window.Echo = new Echo({
   authEndpoint : 'http://*******/public/broadcasting/auth',
    broadcaster: 'pusher',
    key: '********',
    cluster: '***',
    encrypted: true
});
Sloven answered 9/5, 2017 at 12:8 Comment(0)
C
13

Complete These Steps

1) In config/app.php uncomment this line-

App\Providers\BroadcastServiceProvider::class,

2) If above not work and still you've got the error - then I'm sure you are not logged in. Just login to your account and check(because it's your private broadcast).

It'll solve your issue and since you can also pass additional auth parameters as your need in app\Providers\BroadcastServiceProvider.php

Broadcast::routes(['middleware' => 'auth:admin']);
Counterproposal answered 19/2, 2018 at 3:33 Comment(1)
"Logged in" to? Laravel Auth system? What if I am using token based, JWT?Verity
P
2

UnComment this line in config/app.php :

App\Providers\BroadcastServiceProvider::class,

and sure cache is clear with :

php artisan config:cache

Done...

Paedogenesis answered 5/5, 2021 at 11:37 Comment(0)
A
2

Laravel 11:

check bootstrap/app.php. It should contain channels param with correct path to the file:

return Application::configure(basePath: dirname(__DIR__))
->withRouting(
    web: __DIR__.'/../routes/web.php',
    api: __DIR__.'/../routes/api.php',
    commands: __DIR__.'/../routes/console.php',
    //this line:
    channels: __DIR__.'/../routes/channels.php',
    health: '/up',
)
Anachronistic answered 4/6 at 15:50 Comment(0)
L
1

Are you missing csrf_token() in your blade file?

You can add in the meta tag

<meta name="csrf-token" content="{{ csrf_token() }}">

Check out your BroadcastServiceProvider.php and you should include your channel routes in the boot method.

Loudspeaker answered 22/3, 2017 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.