1

I'm trying to make a proxy with the express and request module. This post shows how to easily pipe() the request to the response:

app.use(express.json());       // to support JSON-encoded bodies
app.use(express.urlencoded()); // to support URL-encoded bodies
//app.use(express.multipart());

app.use('/api', function(req, res) {
  var url =proxyUrl + req.url;
  req.pipe(request(url)).pipe(res);
});

It works very well for all GET request. But on a POST request it fails. Can't figure out what is happening because it only runs into a timeout. The POST request works on the proxy.

What am I doing wrong? Is there any changes that I can debug the request? I have tried the following, but the file is empty:

req.pipe(fs.createWriteStream("test.txt"));
Community
  • 1
  • 1
Jan Hommes
  • 5,122
  • 4
  • 33
  • 45

1 Answers1

0

We are also experiencing same issues, its because express.json(). After disabling json parser, it work ok. But that not the idle solution as you might need json parser.

vkadam
  • 211
  • 2
  • 6