title: How to Programmatically execute a node.js file from vb.net
body: <p>I attempting to use ASP and vb.net to run a node.js file that returns a port number from Bungie's API. The issue I am having is that I can use this application locally, but not if I were to publish and deploy the code. The way I do this in Visual Studio is open the Package Manager Console, type in "node proxy.js," and copy the returned value (proxy.js is the node file I'm executing). Then I'd take that port number and add it into my code.</p>
  
  <p>Obviously, this isn't the ideal way to execute this file. So, my question is: is there a way I can execute this file from the code behind in VB.NET? Or, is there a way that I can take my node file and execute it in VB? Here is the proxy.js file I'm working with:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var https = require('https');
  var http = require('http');
  
  var BUNGIE = {
    host: 'www.bungie.net',
    port: 443
  };
  
  function copyHeaderFrom(source) {
    return function (target, k) {
      if (typeof target[k.toLowerCase()] === 'undefined') {
        target[k] = source[k];
      }
      return target;
    };
  }
  
  http.createServer(function (req, res) {
  
    var outboundData = {
      method: req.method,
      host: BUNGIE.host,
      port: BUNGIE.port,
      path: req.url,
      headers: req.headers
    };
  
    console.log('req.headers.cookie:', req.headers.cookie);
  
    outboundData.headers.host = BUNGIE.host;
  
    console.log('outbound request ========================');
    console.log(outboundData);
  
    if (outboundData.method === 'OPTIONS') {
      res.writeHead(200, {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Headers': outboundData.headers['access-control-request-headers'] || ''
      });
      return res.end();
    }
  
    https.request(outboundData, function (bungieRes) {
      var initialHeaders = {
        'access-control-allow-origin': '*',
        'origin': outboundData.headers.origin
      };
      res.writeHead(
        bungieRes.statusCode,
        Object.keys(bungieRes.headers).reduce(copyHeaderFrom(bungieRes.headers), initialHeaders)
      );
      bungieRes.pipe(res);
    }).end();
  
  }).listen(process.argv[2], function () {
    console.log('Bungie Proxy Server running on port %s', this.address().port);
  });</code></pre>
  </div>
  </div>
  </p>