hjbdev/laravel-pusher-batch-auth

支持 dirkbonhomme/pusher-js-auth npm 包的包

1.0.1 2022-03-22 14:05 UTC

This package is auto-updated.

Last update: 2024-09-06 13:32:34 UTC


README

为 Laravel 提供对 dirkbonhomme/pusher-js-auth 的支持的包。

Latest Version on Packagist Total Downloads

composer require hjbdev/laravel-pusher-batch-auth

注册了 /broadcasting/auth/batch 路由,请将您的认证请求发送到该路由。

// routes/web.php
Route::pusherBatchAuth();

您可能需要在 app/Http/Middleware/VerifyCsrfToken.php 中为此路由添加一个例外。

protected $except = [
    'broadcasting/auth/batch'
];

示例

import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
import PusherBatchAuthorizer from 'pusher-js-auth';

const echo = new Echo({
    broadcaster: 'pusher',
    client: new Pusher(process.env.MIX_PUSHER_APP_KEY, {
        authEndpoint: '/broadcasting/auth/batch',
        authorizer: PusherBatchAuthorizer,
        authDelay: 500,
        forceTLS: true,
        cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    }),
});