Replies: 4 comments 1 reply
-
Looks similar to this issue #204 |
Beta Was this translation helpful? Give feedback.
-
After doing some research, it seems with the not working example, express never hits the middleware function at http-proxy-middleware/lib/index.js Line 38 in bb59c66 This means Why express middleware not working for /socket.io? I do not know.. |
Beta Was this translation helpful? Give feedback.
-
I tried using plain Websockets in case it was a socket.io problem and it looks like express middleware does not seem to catch any of it. I saw there are libraries to add middleware for websockets but it seems like a solution to my problem is to not use middleware at all. I can simply do const app = express();
const proxy = require('http-proxy-middleware');
const wsProxy = proxy('/socket.io', {target:'ws://my-websocket.com/', changeOrigin: true, ws:true});
const server = app.listen(...);
server.on('upgrade', wsProxy.upgrade); |
Beta Was this translation helpful? Give feedback.
-
Add |
Beta Was this translation helpful? Give feedback.
-
Proxying works fine when I use
but it does not work if I use
Am I doing this wrong, or is this a bug?
Beta Was this translation helpful? Give feedback.
All reactions