title: Making request to remote server from localhost getting preflight Request 'Access-Control-Allow-Origin'
body: <p>Complete error is this: </p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://ip:port/path" rel="nofollow noreferrer">http://ip:port/path</a>. Response to preflight
    request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>' is therefore not allowed
    access.</p>
  </blockquote>
  
  <p>Environment Details: </p>
  
  <p>Exhausted tried almost everything, but can't accomplish task.</p>
  
  <p>Actually I am requesting node.js server, from angular js client. I have tried all possible options. </p>
  
  <p>Flow is in this way:</p>
  
  <ol>
  <li>Request initiated from web portal designed in angular js.</li>
  <li>Hit node.js server on remote machine.</li>
  </ol>
  
  <p>What I have tried so for </p>
  
  <p><a href="https://github.com/expressjs/cors" rel="nofollow noreferrer">expressjs/cors</a> and 
  <a href="https://www.youtube.com/watch?v=cUWcZ4FzgmI" rel="nofollow noreferrer">Solving "Access-Control-Allow-Origin" in localhost NodeJS + Express</a></p>
  
  <p>Client End Code</p>
  
  <hr>
  
  <pre><code>$scope.testFunc = function () {
      $("div#preloader").show();
      $http.post(rtcControlUrl, data).success(function () {
          $("div#preloader").hide();
          if(response.success)
              $.notify(response.msg, "success");
          else $.notify(response.msg);
          console.log(response.data);
      }).error(function () {
          $.notify("Request timeout!");
          $("div#preloader").hide();
      });
  };
  
  app.post("/path", cors(), function(req, res) {
             shelljs.exec("bash test.sh",{silent:true,async:false}).output;
                      console.log(output);
                      res.json({"success": true, msg: 'some text', 'data' : output});
              }
      });
  </code></pre>