laravel - 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)进行实时聊天..它在我的本地机器上工作..但是当我部署到服务器..这是错误说:https ://ibb.co/QKxFDmJ
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]
广播.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',
],
],
引导程序.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
});
解决方案
推荐阅读
- java - QueryDsl Projections 将字段留空
- javascript - 内部函数如何获取'dispatch'参数?
- c - 在C中找到三个整数的最大整数
- python-3.x - 在循环中使用颜色图(python)
- f# - 从公共字符串生成 href 值和路由模式
- mysql - 从历史表中查询项目
- jenkins - 如何使用 jenkins 向 microsoft team\skype 发送管道更改(提交)通知
- python - 尝试在 Google Colab 上安装 xlwings
- django - django:我不小心删除了 manage.py 文件。如何恢复它?
- amazon-web-services - 如何在 aws EC2 中设置 Sockect.io 服务器,然后远程连接到服务器?