0

I have a Node.js API gateway that passes requests to my different services. It seems to pass the URL correctly (expected) but it is not passing req.body to my other services, in this case my auth service.

Here is my route

router.post('/signup', (req, res) => {
  request.post(req.path, options, (error, response, body) => {
    if (error) throw error;
    res.send(body);
  });
});

Here is my route in my auth service

router.post('/signup', (req, res) => {
    console.log(req.body);
    res.send(req.body)

});

I am getting back {} as my response to the API gateway so it seems like my req.body is not being passed through to my auth service. I'm not sure the correct way to have it pass through the whole req object to the auth service while using the request package.

EDIT**

I think that I need to include form: {key:'value'}}, somewhere in the request where I include req.body as part of the form data. Not sure how this would work since I already have the options included to set my base URL which is dynamic based off a setInterval elsewhere in my code.

options = {
    baseUrl : serviceURL
  }
joshk132
  • 1,011
  • 12
  • 37

0 Answers0