title: Redirect domain to another domain in Meteor
body: <p>I have two domain names, one which I've been using for a long time (<a href="http://blainehansenpianostudio.com/" rel="nofollow noreferrer">blainehansenpianostudio.com</a>), and another simplified one I'm now using (<a href="http://blainehansenpiano.com/" rel="nofollow noreferrer">blainehansenpiano.com</a>). I'm hosting with <a href="https://www.digitalocean.com/" rel="nofollow noreferrer">Digital Ocean</a>, and my DNS is set up so that both domains point to my droplet, and both show up correctly with my site.</p>
  
  <p><strong>However</strong>, I want blainehansenpianostudio.com (the longer, more annoying one) to completely redirect to blainehansenpiano.com, but currently it just acts as an alias, showing the same site but also keeping its annoyingly long url.</p>
  
  <p>The only things I've been able to dig up about http redirection are <a href="http://www.meteorpedia.com/read/HTTP_Redirects" rel="nofollow noreferrer">this meteorpedia article</a> and this <a href="https://stackoverflow.com/questions/22708468/redirect-to-an-external-url-using-meteor-router">stackoverflow question</a>. Neither of these seem to be taking into account the existence of a secondary domain, and are using the in-app routing system. That doesn't seem to be the correct solution, since the redirect should be happening even before the bundle is sent right? I don't want a bunch of extraneous redirects happening within my app.</p>
  
  <p>Also, the SO question has this line:</p>
  
  <blockquote>
    <p>The easiest way to achieve this is to put the redirect in middleware:</p>
  </blockquote>
  
  <p>which doesn't mean anything to me. Where is "middleware"?</p>
  
  <p>How do I go about accomplishing this? I feel like I need to change something in the server setup, but I deployed with <a href="https://github.com/arunoda/meteor-up" rel="nofollow noreferrer">Meteor Up</a>, which doesn't mention anything about redirects, and am not sure where the server config I need even is.</p>
  
  <p>Thanks in advance!</p>
  
  <h2>Update</h2>
  
  <p>I tried putting the following code in my <code>lib/router.js</code> file, just to test things out and see if the router is the "middleware" in question:</p>
  
  <pre><code>WebApp.connectHandlers
      .use(function(req, res, next) {
          console.log(req);
          console.log(res);
          console.log(next);
          next();
      });
  </code></pre>
  
  <p>but it absolutely wasn't. It just broke the router.</p>
  
  <h2>Possible (but messy) Solution</h2>
  
  <p>Putting this client-side redirect code into <code>main.js</code>:</p>
  
  <pre><code>if (window.location.href.indexOf("blainehansenpianostudio") &gt; -1) {
      window.location = "http://blainehansenpiano.com";
  }
  </code></pre>
  
  <p>works, but it seems to lag for a moment after the redirect is made. It seems to me that this is triggering two entirely separate server requests, which is not at all ideal.</p>