Ubuntu Node js With Socket io 不允许客户端连接
Ubuntu Node js With Socket io Not allowing client to connect
我正在尝试使用 Nodejs 让 socket.io 在 Ubuntu 中工作。
尝试禁用防火墙,打开端口 3000,4000。
我正在使用 PM2。
部署在DigitalOcean
现在在我的 Angular 客户端应用程序中出现此错误
我的节点 js 中也有核心错误设置
client:1 Access to XMLHttpRequest at 'mydomain.com/socket.io/?EIO=3&transport=polling&t=N4_SuJm'
'Access-Control-Allow-Origin' header is present on the requested resource.
虽然我确实在 AWS ElasticBeanstalk 中发布了相同的代码并且它工作得很好所以代码没有问题
更新
我成功解决了问题
更新
我成功解决了问题
For future reference
the problem was that the socketio client removes the path from the url
that is given when connecting exampledomin.com/api is the correct path
for socketio in node js but the socket io client removes the /api and
points it to /socketio so i added a Location in the nginx config to
point to the server hope this will help someone down the road
我正在尝试使用 Nodejs 让 socket.io 在 Ubuntu 中工作。 尝试禁用防火墙,打开端口 3000,4000。
我正在使用 PM2。
部署在DigitalOcean
现在在我的 Angular 客户端应用程序中出现此错误
我的节点 js 中也有核心错误设置
client:1 Access to XMLHttpRequest at 'mydomain.com/socket.io/?EIO=3&transport=polling&t=N4_SuJm'
'Access-Control-Allow-Origin' header is present on the requested resource.
虽然我确实在 AWS ElasticBeanstalk 中发布了相同的代码并且它工作得很好所以代码没有问题
更新
我成功解决了问题
更新
我成功解决了问题
For future reference
the problem was that the socketio client removes the path from the url that is given when connecting exampledomin.com/api is the correct path for socketio in node js but the socket io client removes the /api and points it to /socketio so i added a Location in the nginx config to point to the server hope this will help someone down the road