[英]CORS Missing Allow Origin on Laravel Echo Server with Socket.io and Redis
Hi I am getting Following error after adding on my view page of laravel application.嗨,我在 laravel 应用程序的查看页面上添加后出现以下错误。
I am using Windows 10.我正在使用 Windows 10。
CORS Missing Allow Origin CORS 缺少允许来源
Following Steps will resolve "CORS Missing Allow Origin" Error for your Echo Server以下步骤将为您的 Echo 服务器解决“CORS Missing Allow Origin”错误
STEP-1: Add "transports: ['websocket', 'polling', 'flashsocket'] // Fix CORS error."第 1 步:添加“传输:['websocket', 'polling', 'flashsocket'] // 修复 CORS 错误。” Code inside your Echo Server Setup File (public\js\laravel-echo-setup:js) like following code:
您的 Echo 服务器设置文件 (public\js\laravel-echo-setup:js) 中的代码如下所示:
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
transports: ['websocket', 'polling', 'flashsocket'] // Fix CORS error!
});
STEP-2: Build Your Code Using "npm run dev" command Restart your Laravel Echo Server Using "laravel-echo-server start" command Now check your application, You can't find a CORS error now.第 2 步:使用“npm run dev”命令构建代码使用“laravel-echo-server start”命令重新启动 Laravel Echo 服务器现在检查您的应用程序,您现在找不到 CORS 错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.