We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3355b3 commit f901a2dCopy full SHA for f901a2d
src/index.ts
@@ -44,7 +44,16 @@ const httpProxyMiddleware = async (
44
if (pathRewrite) {
45
req.url = rewritePath(req.url as string, pathRewrite);
46
}
47
+ if(["POST", "PUT"].indexOf(req.method as string) >= 0 && typeof req.body === "object"){
48
+ req.body = JSON.stringify(req.body);
49
+ }
50
proxy
51
+ .once("proxyReq", ((proxyReq: any, req: any): void => {
52
+ if(["POST", "PUT"].indexOf(req.method as string) >= 0 && typeof req.body === "string"){
53
+ proxyReq.write(req.body);
54
+ proxyReq.end();
55
56
+ }) as any)
57
.once("proxyRes", resolve)
58
.once("error", reject)
59
.web(req, res, {
0 commit comments