Laravel CORS 在 https://sockjs.pusher.com/pusher/app/AB/13/heelec9r/xhr_streaming?protocol=7&client=js&version=7.0.3&t=162&n=6 处访问 XMLHttpRequest

问题描述

请帮忙..我正在使用laravel websocket(https://beyondco.de/docs/laravel-websockets/getting-started/introduction)进行实时聊天..它在我的本地机器上工作..但是当我部署到服务器..这是错误说:{{ 3}}

Access to XMLHttpRequest at 'https://sockjs.pusher.com/pusher/app/ABCDEFG/232/15de5kkf/xhr?protocol=7&client=js&version=7.0.3&t=1622612993897&n=52' from origin 'http://ipaddress' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
app.js:24458 POST https://sockjs.pusher.com/pusher/app/ABCDEFG/232/15de5kkf/xhr?protocol=7&client=js&version=7.0.3&t=1622612993897&n=52 net::ERR_Failed[![enter image description here][1]][1]

broadcasting.PHP

'pusher' => [
            'driver' => 'pusher','key' => env('PUSHER_APP_KEY'),'secret' => env('PUSHER_APP_SECRET'),'app_id' => env('PUSHER_APP_ID'),'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),'host' => '127.0.0.1','port' => 6001,'scheme' => 'http',],

bootstrap.js

window.Echo = new Echo({
    broadcaster: 'pusher',key: process.env.MIX_PUSHER_APP_KEY,wsHost: window.location.hostname,wsPort: 6001,wssport: 6001,disableStats: true,forceTLS: true
});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)