title: res.redirect in express returns the html source code & not just the URL
body: <p>I'm trying to redirect a user to a login page when they click a button but instead of a redirect I get html source code and nothing happens.</p>
  
  <p>Here's my redirect method in express: </p>
  
  <pre><code>function redirect(req, res) {
      res.redirect("https://dev-krbec.authentication.eu10.hana.ondemand.com/login");
  };
  </code></pre>
  
  <p>Here's how it's called from the client with a simple get query:</p>
  
  <pre><code>$.get({
                  url: document.URL + "api/redirect",
                  success: function (data) {
                      console.log(data);
                      // window.location.href=data;
                  },
                  error: function (err) {
                      console.log(err);
                  }
              });
  </code></pre>
  
  <p>However, the redirect is never performed and I only get a data variable with the whole html source code of page I want to redirect to. </p>
  
  <p>This is how the query looks:
  <a href="https://i.stack.imgur.com/a9dNu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a9dNu.png" alt="enter image description here"></a></p>
  
  <p>This is a response that should contain just the URL but it contains html source code instead:
  <a href="https://i.stack.imgur.com/B96gD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B96gD.png" alt="enter image description here"></a></p>
  
  <p>Am I missing something?</p>