Laravel与推送器广播/身份验证出现403错误

时间:2019-09-20 21:32:50

标签: laravel

Laravel 5.6.32 我目前通过composer

安装了一个软件包
composer require launcher/mercurius

安装软件包后,我不断得到:

Failed to load resource: the server responded with a status of 403 (Forbidden) 

127.0.0.1:8000/broadcasting/auth

在检查我的项目构建时,在我的项目中看到使用以下代码的routes / channels.php:

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

在这种情况下,在实际供应商包装内: 我看到了vendor / launcher / mercurius / routes / channels.php

// User private channel
Broadcast::channel('mercurius.{slug}', function ($user, $slug) {
    return (string) $user->{config('mercurius.fields.slug')} === (string) $slug;
});

// User conversation channel
Broadcast::channel('mercurius.conversation.{slug}', function ($user, $slug) {
    return true;
});

在与此相关的js文件中,我有:

 this._defaultOptions = {
        auth: {
            headers: {}
        },
        authEndpoint: '/broadcasting/auth',
        broadcaster: 'pusher',
        csrfToken: null,
        host: null,
        key: null,
        namespace: 'App.Events'
    };
    this.setOptions(options);
    this.connect();
}

我想知道这是否与使用的第一个路由/通道而不是供应商文件夹中定义的路由有关?让我失望的是,我没有像在api路由或网络路由中那样以传统方式看到为“广播/身份验证”定义的路由。

0 个答案:

没有答案