title: Express Middleware not setting CORS header
body: <p>I am trying to set the CORS headers on an express app and I can't figure out why It's not working:</p>
  
  <pre><code>app.use(function(req, res, next){
      res.append('Access-Control-Allow-Origin','*');
      res.set("Access-Control-Allow-Methods","GET, POST, OPTIONS");
      res.set("Access-Control-Allow-Headers","Content-Type, Authorization, Content-Length, X-Requested-With");
      if ("OPTIONS" == req.method){
          res.send(200);
      }
      console.log("Set CORS Header");
      next();
  });
  </code></pre>
  
  <p>I have tried using res.header, res.setheader and res.append also and all have not set the header correctly, but the "Set CORS Header" message appears on the console everytime a request comes through.</p>
  
  <p>Edit: looks like it might be something to do with AWS EC2?</p>
  
  <p>The full server code is here: <a href="https://github.com/rossgriebenow/wkdu-music-webapp/blob/master/WKDU_SQL.js" rel="nofollow noreferrer">https://github.com/rossgriebenow/wkdu-music-webapp/blob/master/WKDU_SQL.js</a></p>