How do I receive an http request with a Node.js server and then pass that request along to another server?

There's a lot going on here so I'll simplify this into a pseudo example. Forget about security and whatnot for a minute here. The point is to understand the functionality.

Let's say I'm running a local web server with node.js to dev a website. In the website, the user should be able to create a new account. The account information will be submitted via ajax to the node server. I then need the node server to take the incoming request and pass it along to another server that gives me access to a database. CouchDB, for example.

So here's a pseudo example of what I'd like to happen.

In the client's browser:

$.ajax({
  url: './database_stuff/whatever', // points to the node web server
  method: 'POST',
  data: {name: 'Billy', age: 24}
});

In the Node web server:

var http     = require('http'),
    dbServer = 'http://127.0.0.1:5984/database_url';

http.createServer(function (req, res) {
  /* figure out that we need to access the database then... */

  // magically pass the request on to the db server
  http.magicPassAlongMethod(req, dbServer, function (dbResponse) {

    // pass the db server's response back to the client
    dbResponse.on('data', function (chunk) {
      res.end(chunk);
    });
  })
}).listen(8888);

Make sense? Basically what's the best way to pass the original request along to another server and then pass the response back to the client?

If the server at dbServer url supports streaming you could do something like

var request = require('request');
req.pipe(request.post(dbServer)).pipe(res)

where request is a module, for more info look here https://github.com/mikeal/request

This is quite readable and easy to implement, if for whatever reason you cannot do this then you could take what you need from the request and manually POST it, then take the response and res.send it to the client.

Sorry if there's an error in my code, I haven't tested it but my point should be clear, if it's not then ask away.