0

I'm trying to get node-http-proxy working with AppJS. Unfortanly it crashes on launch of the app. What I did:

  • Download & extracted AppJS from http://appjs.com/;
  • Installed node-http-proxy with npm install http-proxy;
  • Edited the app.js window.on(create) function:

    window.on('create', function(){
    console.log("Window Created");
    window.frame.show();
    window.frame.center();
    window.frame.setMenuBar(menubar);
    
    var http = require('http'),
    httpProxy = require('http-proxy');
    // 
    // Create your proxy server and set the target in the options. 
    // 
    httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
    
    // 
    // Create your target server 
    // 
    http.createServer(function (req, res) {
      res.writeHead(200, { 'Content-Type': 'text/plain' });
      res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
      res.end();
    }).listen(9000);
    });
    

When the app starts I want to start the nodeJS proxy server. Is it possible to connect from a external PC to this proxy server? (I know I will need to open ports for this)

For example if I run the app on my home PC and at work I will set the proxy settings of the work PC to homePC_IP:8000. Will this work?

Mark
  • 41
  • 6
  • Have you tried? Do you have reason to believe it won't work? – Andrew Lavers May 11 '15 at 23:06
  • I did try, when I use locahost:8080 as proxy it works. When I setup a Wifi hotspot with my mobile phone on 4G and using my home IP:8080 it doesn't work, I did open port 8080 and port 80 on my router. Am I missing a step? – Mark May 12 '15 at 04:19
  • After some deep thinking I know why above didn't work :) I used the same PC where proxy server is set.... But I still can't figure out why AppJS is crashing when I add start node-http-proxy? The code provided here: http://www.catonmat.net/http-proxy-in-nodejs/ does work but not for https :( Somebody has a suggestion what goes wrong with node-http-proxy? – Mark May 12 '15 at 06:46

1 Answers1

0

Haven't got a fix for the crash of node-http-proxy but I instead I used https://github.com/TooTallNate/proxy and this works like a charm!

Mark
  • 41
  • 6