Open alanhe421 opened 1 year ago
if (!req.body || !Object.keys(req.body).length) { return; } const contentType = proxyReq.getHeader('Content-Type'); const writeBody = (bodyData: string) => { proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData)); proxyReq.write(bodyData); }; if (contentType.toString().includes('application/json')) { writeBody(JSON.stringify(req.body)); } if (contentType.toString().includes('application/x-www-form-urlencoded')) { writeBody(querystring.stringify(req.body)); }
options比如携带了koa的context,可能会触发该错误
proxyServer.on('proxyReq', (proxyReq, req, res, options) => {
});
这里的socket是TCP Socket并非websocket.
proxy.ws(req, socket, head);
express.json() (body-parser) breaks http-proxy-middleware POST request