Is there a way to pass the request body to express only?

There are 2 web servers in my project, one is nodejs for serving requests from the frontend (authentication, acl management, ...) and the other is stateless Java for real work.

The nodejs server must support a file upload request (multipart / form-data) to the Java server server. I am trying to pass raw loaded file data to a module request

.

app.post('/file/upload', function(req, res, next) {
  req.pipe(request.post('http://java-server/file/upload', function(err, resp, body) {
    if (err) { return next(err); }
    res.json(body);
  }));
});

      

The question is that I am handling the whole request (including headers), not just body data. I can't find any method to get something like req.body.stream()

so that I can directly connect the downloaded file.

This way I cannot insert additional headers such as the Authorization

java server requires.

Anyone help? Thank.

+3


source to share





All Articles