title: Nodejs dynamic OG tags
body: <p>Using Express. Here's the route. It basically just passes the url params into a template that renders the OG tags.</p>
  
  <pre><code>router.get('/share/:redirectURL/:title/:description/:img', function (req, res) {
  
      var url = req.protocol + '://' + req.get('host') + req.originalUrl; // points to this endpoint
  
      res.render('share', {
          url: url,
          title: decodeURIComponent(req.params.title),
          img: decodeURIComponent(req.params.img),
          description: decodeURIComponent(req.params.description),
          redirectURL: decodeURIComponent(req.params.redirectURL)
      });
  
  });
  
  module.exports = router;
  </code></pre>
  
  <p>And here's the share template that it renders to.</p>
  
  <pre><code>doctype html
  html
      head
          meta(property="og:url", content="#{url}")
          meta(property="og:image", content="#{img}")
          meta(property="og:title", content="#{title}")
          meta(property="og:description", content="#{description}")
          meta(property="og:type", content="article")
  
      body
          script.
              location.replace("#{redirectURL}");
  </code></pre>
  
  <p>...and it works! But it only works LOCALLY. As soon as I upload to the server, things go awry.</p>
  
  <p>works: <code>http://localhost/share/http%3A%2F%2Fgoogle.com/Hear%20some%20music./http%3A%2F%2F201.23.456.789%2F%2Fassets%2Fimgs%2Ffavicons%2Ficon1024.png</code></p>
  
  <p>doesn't work: <code>http://123.45.678.910/share/http%3A%2F%2Fgoogle.com/Hear%20some%20music./http%3A%2F%2F201.23.456.789%2F%2Fassets%2Fimgs%2Ffavicons%2Ficon1024.png</code></p>
  
  <p>Something upstream is partially decoding the url BEFORE it gets to the Express router. The result is this confused, useless thing.</p>
  
  <p><code>http://123.45.678.910/share/http:/google.com/Hear%20some%20music./http%3A%2F%2F201.23.456.789%2F%2Fassets%2Fimgs%2Ffavicons%2Ficon1024.png</code></p>