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

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 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 举报,一经查实,本站将立刻删除。