Not able to run socket.io behind proxy. Cannot GET socket.io 404 - Stack Overflow

I am trying to run socket.io behind a Node.js proxy as explained here:const WS_TARGET = 'ws:loc

I am trying to run socket.io behind a Node.js proxy as explained here:

const WS_TARGET = 'ws://localhost:8080'; // Upstream WebSocket server
const wsProxy = createProxyMiddleware({
  target: WS_TARGET,
  ws: true,  // Enable WebSocket proxying
  changeOrigin: true,
  logLevel: 'debug'
});
const app = express();
app.use('/chat', wsProxy)

in my client I have:

const socket = io("http://localhost:3000/chat")

but when I run the client I get a stream of:

2025-03-10 17:59:04:594 warn: GET /socket.io/?EIO=4&transport=polling&t=s9lrd5zc ::ffff:127.0.0.1 - 0.423 ms 404
2025-03-10 17:59:09:599 warn: GET /socket.io/?EIO=4&transport=polling&t=s9pmr8yv ::ffff:127.0.0.1 - 0.212 ms 404
2025-03-10 17:59:14:5914 warn: GET /socket.io/?EIO=4&transport=polling&t=s9ti1i74 ::ffff:127.0.0.1 - 0.101 ms 404

I have put a working demo here and a video of what I see here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744817746a4595429.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信