title: How do I get the URL of the current page in node?
body: <p>I'm trying to build a comments section for a site and I want each comment to have a static URL that is basically domain.com/titles/postID/commentID where postID is the ID of the post the comment is in reply to. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>exports.commentHandler = function(req, res){
      comment = req.body.comment;
      username = req.session.username;
  
      buildpost.comment(comment, username)
  
  };
  </code></pre>
  
  <p>Here's buildpost.comment:</p>
  
  <pre><code>exports.comment = function(comment, username){
      var id = makeid(7);
  
      var comment = {comment: comment, user: username, postID: id, type: "comment"}
  
      console.log(comment);
      postdb.write(comment);
  
  };
  </code></pre>
  
  <p>Here is the relevant code from my app.js file:</p>
  
  <pre><code>app.get('/titles/:id', home.content); //this serves the post's page, where the comments are
  app.post('/comment', home.commentHandler);
  </code></pre>
  
  <p>Here's the jade form:</p>
  
  <pre><code>form.sbBox#commentReply(method='post', action='/comment')
  </code></pre>
  
  <p>If I just use req.url or something along those lines in exports.commentHandler, it returns '/comment' which is the URL of the post request and not the page. </p>