title: Express redirect wrong url
body: <p>When use express res function redirect(url), i'm redirected to the wrong url !</p>
  
  <p>My website URL is mywebsite.com :</p>
  
  <pre><code>function myroute(app) {
      app.get(/route, function(req, res) {
          var url = getMyUrl();
          console.log(url); // https://otherwebsite.com/foo?bar=baz [OK]
          res.redirect(url); // redirect to https://mywebsite.com/foo?bar=baz [WRONG!]
      });
  }
  </code></pre>
  
  <p>I don't know why express redirect to mywebsite.com with good parameters instead of otherwebsite.com</p>
  
  <p>No idea why...</p>
  
  <p>This bug occurs on production. On my develop environment the redirect URL is the good url.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I also tried with:</p>
  
  <pre><code>res.location(url);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>res.setHeader(302, {Location: url});
  </code></pre>
  
  <p>But it always redirect to the wrong URL...
  My url variable is good but I receive this header response:</p>
  
  <pre><code>HTTP/1.1 302 Found
  X-Powered-By: Express
  Location: https://mywebsite.com/foo?bar=baz
  Vary: Accept\r\nContent-Type: text/html; charset=UTF-8
  Content-Length: 170
  Date: Fri, 13 Jul 2018 21:52:18 GMT
  Connection: keep-alive
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Ok more tests here :</p>
  
  <pre><code>res.redirect("https://www.google.fr/toto?key=value"); // https://mywebsite.com/toto?key=value **[fail]**
  
  res.redirect("https://www.google.fr/toto"); // https://mywebsite.com/toto **[fail]**
  
  res.redirect("https://www.google.fr"); // https://www.google.fr **[success]**
  </code></pre>
  
  <p>It seems to not redirect to the domain I want if I add a path. Any idea ?</p>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>Maybe it's caused by my vhost ?</p>
  
  <pre><code>&lt;IfModule mod_ssl.c&gt;
  &lt;VirtualHost *:443&gt;
  ServerName mywebsite.com
  
  ProxyRequests     Off
  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:5001/
  &lt;Location /&gt;
      ProxyPassReverse /
      Order deny,allow
      Allow from all
  &lt;/Location&gt;
  
  SSLCertificateFile ...
  SSLCertificateKeyFile ...
  &lt;/VirtualHost&gt;
  &lt;/IfModule&gt;
  </code></pre>