http-proxy
http-proxy copied to clipboard
how to use createWsClientTransformStream
if i understand correctly, createWsClientTransformStream is for transforming message from client to server, do u have any example on how to use this method? thanks in advance
i have tried this, https://github.com/http-party/node-http-proxy/pull/1301#issuecomment-468059087 does not work
hi @lucaschan1020, the createWsClientTransformStream method is used to transform WS messages between the client and server (in theory).
const proxy = httpProxy.createProxyServer({
ws: true,
target: 'ws://example.com',
createWsClientTransformStream: (req, proxyReq, proxyRes) => {
const { PassThrough } = require('stream');
const transformStream = new PassThrough();
transformStream.on('data', (chunk) => {
const modifiedChunk = chunk.toString().toUpperCase();
proxyReq.write(modifiedChunk);
});
return transformStream;
}
});
I believe it works, can you test it and get back to me (your test code + error)?