首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发布http://localhost:8000/broadcasting/auth 403 (禁止)

发布http://localhost:8000/broadcasting/auth 403 (禁止)
EN

Stack Overflow用户
提问于 2017-12-04 23:03:17
回答 4查看 8.7K关注 0票数 3

我正试图让我的应用程序连接到一个私人频道上的推手。

但是,我在控制台中得到了以下错误:

发布http://localhost:8000/broadcasting/auth 403 (禁止)

app.js

代码语言:javascript
复制
 /**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('payment', require('./components/Payment.vue'));
Vue.component('form-ajax', require('./components/FormAjax.vue'));
Vue.component(
    'passport-clients',
    require('./components/passport/Clients.vue')
);

Vue.component(
    'passport-authorized-clients',
    require('./components/passport/AuthorizedClients.vue')
);

    Vue.component(
    'passport-personal-access-tokens',
    require('./components/passport/PersonalAccessTokens.vue')
);

const app = new Vue({
    el: '#app'
});

Echo.private(`articles.admin`)
    .listen('ArticleEvent', function(e)  {
        console.log(e);
    });

错误

错误的原因可能是什么,以及如何解决。

EN

回答 4

Stack Overflow用户

发布于 2018-05-18 07:26:13

错误403 /广播/auth与Laravel版本> 5.3 & Pusher,您需要在resources/assets/js/bootstrap.js中更改您的代码

代码语言:javascript
复制
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'your key',
    cluster: 'your cluster',
    encrypted: true,
    auth: {
        headers: {
            Authorization: 'Bearer ' + YourTokenLogin
        },
    },
});

而在app/Providers/BroadcastServiceProvider.php

代码语言:javascript
复制
Broadcast::routes()

使用

代码语言:javascript
复制
Broadcast::routes(['middleware' => ['auth:api']]);

代码语言:javascript
复制
Broadcast::routes(['middleware' => ['jwt.auth']]); //if you use JWT

它对我有用,希望它能帮助你。

票数 7
EN

Stack Overflow用户

发布于 2022-02-23 05:55:26

你有没有试过定制你的authEndpoint。

这东西在我这边管用。

bootsrap.js

代码语言:javascript
复制
window.Echo = new Echo({
    broadcaster: 'pusher',
    // ...
    authEndpoint: '/custom/endpoint/auth'
});
票数 2
EN

Stack Overflow用户

发布于 2018-04-26 00:27:50

在我的例子中,我使用了一个造成问题的自定义警卫。

我添加了中间件来通过我的自定义安全机制,这解决了这个问题。

代码语言:javascript
复制
public function boot()
{
    Broadcast::routes(['middleware' => 'auth:admin']);

    require base_path('routes/channels.php');
}

链接更详细地解释了发生了什么。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47643417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档