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