Search code examples
laravelserverredissocket.iolaravel-echo

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


Solution

  • 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.