Laravel Echo 服务器无法通过身份验证,获得 HTTP 状态 500

Laravel Echo Server can not be authenticated, got HTTP status 500

我都安装了 Laravel echo server and Laravel echo client

以下是laravel-echo-server.json配置。

{
"authHost": "http://taxation.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
    {
        "appId": "APP_ID",
        "key": "someKey"
    }
],
"database": "redis",
"databaseConfig": {
    "redis": {},
    "sqlite": {
        "databasePath": "/database/laravel-echo-server.sqlite"
    }
},
"devMode": true,
"host": "127.0.0.1",
"port": "3000",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": ""
}

以下脚本侦听通道事件。 npm run dev.

构建良好
import Echo from 'laravel-echo'
let token = document.head.querySelector('meta[name="token"]');
if (token) {
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: '127.0.0.1:3000',
    reconnectionAttempts: 5
});


window.Echo.join('checked-in-1')
            .listen('.user.checked_in', (e) => {
            console.log(e);
        });

尝试监听 start laravel-echo-server 命令上的任何事件时。它一直在抛出 Client can not be authenticated, got HTTP status 500.

注:

我真的没有在 laravel-echo-serve 和 google.

上找到任何有用的东西

任何帮助将不胜感激。

Laravel V5.4

谢谢

刚遇到问题是因为 CSRF 令牌。没有将令牌传递给回显。

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: '127.0.0.1:3000',
    reconnectionAttempts: 5,
    csrfToken: token.content <--
});