微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在此服务器上找不到请求的 URL“localhost/pusher/auth”

如何解决在此服务器上找不到请求的 URL“localhost/pusher/auth”

我正在尝试使用 laravel 作为后端和 reactjs 作为前端构建一个视频聊天 Web 应用程序。我试图在这里找到错误,但我不能。请帮我改正错误

显示错误

1/ 发布 http://localhost/pusher/auth 404 (Not Found)

2/ Pusher :: ["Error: Unable to retrieve auth string from auth endpoint - received status: 404 from /pusher/auth。客户端必须经过身份验证才能加入私有或在线通道。请参阅:https://pusher.com/docs/authenticating_users"]

我的代码来自“resources/js/components/App.js”

setupPusher(){
    
    Pusher.logToConsole = true;
    this.pusher = new Pusher(APP_KEY,{
        authEndpoint: '/pusher/auth',cluster: 'ap2',auth:{
            params: this.user.id,headers:{
                'X-CSRF-Token': window.csrftoken
            }
        }
    });

    this.channel = this.pusher.subscribe('presence-video-channel');

    this.channel.bind(`clnt-signal-${this.user.id}`,(signal) => {
        let peer = this.peers[signal.userId];

        // if peer is not already exists,we got an incoming call
        if(peer == undefined){
            this.setState({otherUserId: signal.userId});
            peer = this.startPeer(signal.userId,false);
        } 
        peer.signal(signal.data);
    });
}

我的代码来自“routes/web.PHP

 Route::post('/pusher/auth',[App\Http\Controllers\HomeController::class,'authenticate']);

我的代码来自“app/Http/Controllers/HomeController.PHP


public function authenticate(Request $request){
    
    $socketId = $request->socket_id;
    $channelName = $request->channel_name;

    $pusher = new Pusher('a384f250f86af1f16f98','d30d380941bdec2e4e55','1147033',[
        'cluster' => 'ap2','useTLS' => true
    ]);

    $presence_data = ['name' => auth()->user()->name];
    $key = $pusher->presence_auth($channelName,$socketId,auth()->id(),$presence_data);

    return response($key);
}



版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。