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条)