title: openshift nodejs app cors 502 No Access-Control-Allow-Origin specified
body: <p>I am building some prototype api's using the openshift default node.js app but for some reason I am getting a No Access-Control-Allow-Origin header specified error with the following code, can someone explain what I am doing wrong:</p>
  
  <pre><code>self.createRoutes = function() {
  
          self.routes = { };
  
          self.routes['/api/getusers/:username'] = function(req, res) {
  
              res.header('Access-Control-Allow-Origin', '*');
              res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
              res.header('Access-Control-Allow-Headers', 'Content-Type');
  
              client.users.search({query: req.params.username}, function (err, req, result) {
                if (err) {
                  console.log(err);
                  res.json({'err':JSON.parse(err)});
                  return;
                }
                res.json({'success': result});
              });
  
          };
  
  ...
  </code></pre>
  
  <p>I have used similar headers on other projects and it works fine, I am guessing some sort of scope issue here but can't seem to figure it out.  Thanks.</p>