How can I fix Cross-Origin laravel-echo-server Error?

Viewed 1285

I have a problem with laravel-echo-server, I have two laravel projects which installed on two separate domains, one of these projects has laravel-echo and on another one has laravel-echo-server.

When I want to connect from the client to the server, I get the cross-origin error!?

my laravel echo server config:

{
    "authHost": "https://{domain}.net",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "{myapp}",
            "key": "{mykey}"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "localhost"
        },
        "publishPresence": true,
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "ws",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": true,
        "allowOrigin": "*",
        "allowMethods": "*",
        "allowHeaders": "*"
    }
}

How can I fix that?

It would be highly appreciated if anyone can advise me!

1 Answers

In laravel 7 you must find a file named cors.php inside the config directory where you can conigure the cors for your project

Related