title: Node.js/Express - Ajax calls from local/external- network
body: <p>I have a express instance listening on 3000.<br>
  A Http-server listening on 8080 and cors-proxy running on 1337 relaying info between them.<br>
  (npm http-server and npm cors-proxy, both installed globaly)  </p>
  
  <p>I can access the website from both local- and external-networks, but none of the ajax calls goes through. There are no POST/GET requests on the http-server when I launch the AJAX calls either. </p>
  
  <p>Error from local network:  </p>
  
  <pre><code>net::ERR_CONNECTION_REFUSED  
  </code></pre>
  
  <p>Error from external network:  </p>
  
  <pre><code>No 'Access-Control-Allow-Origin' header ....  
  </code></pre>
  
  <p>My AJAX post request:  </p>
  
  <pre><code>$.ajax({
              method: "POST",
              //url: "http://localhost:1337/localhost:3000/name/"+inputText,
              url: "http://192.168.10.50:1337/192.168.10.50:3000/name/"+inputText,
              data: {"data": "Hello world"},
              success: (data) =&gt; {
                  console.log("Success" + data);
              };
  });  
  </code></pre>
  
  <p>I've tried to add code in my node file to allow this:    </p>
  
  <pre><code>app.use(function(req, res, next){
      res.header('Access-Control-Allow-Origin', "*");
      res.header('Access-Control-Allow-Methods', 'GET, POST');
      red.header('Access-Control-Allow-Headers', 'Content-Type');
      next();
  })  
  </code></pre>
  
  <p>But nothing changes.  </p>
  
  <p>How can I tell the http-server to let requests pass though from local and external networks?</p>