fixes http headers being set in wrong order
This commit is contained in:
parent
45451c4486
commit
c74c527f46
|
@ -22,16 +22,15 @@ const rewriteRequest = (proxyReq: http.ClientRequest, req: Request) => {
|
||||||
proxyReq.setHeader("Authorization", `Bearer ${key.key}`);
|
proxyReq.setHeader("Authorization", `Bearer ${key.key}`);
|
||||||
|
|
||||||
if (req.method === "POST" && req.body) {
|
if (req.method === "POST" && req.body) {
|
||||||
// body-parser and http-proxy-middleware don't play nice together
|
|
||||||
fixRequestBody(proxyReq, req);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.body?.stream) {
|
if (req.body?.stream) {
|
||||||
req.body.stream = false;
|
req.body.stream = false;
|
||||||
const updatedBody = JSON.stringify(req.body);
|
const updatedBody = JSON.stringify(req.body);
|
||||||
proxyReq.setHeader("Content-Length", Buffer.byteLength(updatedBody));
|
proxyReq.setHeader("Content-Length", Buffer.byteLength(updatedBody));
|
||||||
proxyReq.write(updatedBody);
|
(req as any).rawBody = Buffer.from(updatedBody);
|
||||||
proxyReq.end();
|
}
|
||||||
|
|
||||||
|
// body-parser and http-proxy-middleware don't play nice together
|
||||||
|
fixRequestBody(proxyReq, req);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue