title: CORS with Express.js and Angular2
body: <p>I'm trying to download a PLY file from my remote Express.js server to my Angular/Ionic app. I have my Ionic app hosted on Amazon AWS right now. Here's the Typescript from the Ionic app:</p>
  
  <pre><code>//this.currentPlyFile encompasses entire URL
  document.getElementById('entity').setAttribute("ply-model", "src: url(" + this.currentPlyFile + ".ply);");
  </code></pre>
  
  <p>I have the following in my Express.js server:</p>
  
  <pre><code>app.use(function(req, res, next) {
          res.header('Access-Control-Allow-Credentials', true);
          res.header('Access-Control-Allow-Origin', '*');
          res.header('Access-Control-Allow-Methods', 'GET,POST');
          res.header('Access-Control-Allow-Headers', 'appid, X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
          if ('OPTIONS' == req.method) {
              res.send(200);
          } else {
              next();
          }
      });
  </code></pre>
  
  <p>But I get the following error when requesting the PLY file:</p>
  
  <pre><code>XMLHttpRequest cannot load "my url here" No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my url here' is therefore not allowed access.
  </code></pre>
  
  <p>This is really frustrating because I am using headers provided by the Express.js documentation to allow CORS.</p>