问题描述
我正在尝试使用 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);
});
}
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 (将#修改为@)