简体   繁体   中英

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.

I am using Windows 10.

CORS Missing Allow Origin

CORS Missing Allow Origin Error Screenshot

Following Steps will resolve "CORS Missing Allow Origin" Error for your Echo Server

STEP-1: Add "transports: ['websocket', 'polling', 'flashsocket'] // Fix CORS error." Code inside your Echo Server Setup File (public\js\laravel-echo-setup:js) like following code:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM