After deploying fixed-laravel-echo-server, the client side link keeps prompting 400 (Bad Request), can you help me?
"laravel-echo": "^1.16.1",
"socket.io-client": "^4.7.5",
import Echo from 'laravel-echo'
import io from 'socket.io-client'
window.io = io
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'test.com',
auth: {
headers: {
Authorization:
'Bearer request token'
}
}
})
window.Echo.private('im.chat.message.12345').listen('.chat.message', (e) => {
console.log( e)
})
NGINX server
#the following would go within the server{} block of your web server config
location /socket.io {
proxy_pass http://127.0.0.1:6001; #could be localhost if Echo and NginX are on the same box
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
ERROR:
Access to XMLHttpRequest at 'http://test.com/socket.io/?EIO=3&transport=polling&t=OyJ3I6q' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
[root@test test.com]# curl http://127.0.0.1:6001?EIO=3&transport=polling&t=OyJIoDI
[1] 154304
[2] 154305
[root@test test.com]# {"success":true,"message":"OK","headers":["*/*"]}
clientConnectEndpoint and clientDisconnectEndpoint must be set?
After deploying fixed-laravel-echo-server, the client side link keeps prompting 400 (Bad Request), can you help me?
"laravel-echo": "^1.16.1",
"socket.io-client": "^4.7.5",
NGINX server
ERROR:
Access to XMLHttpRequest at 'http://test.com/socket.io/?EIO=3&transport=polling&t=OyJ3I6q' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.clientConnectEndpoint and clientDisconnectEndpoint must be set?