Node.js 如何配置AppJS以使用节点http代理服务器
我正在尝试让节点http代理与AppJS一起工作。不幸的是,它在应用程序启动时崩溃了。我所做的:Node.js 如何配置AppJS以使用节点http代理服务器,node.js,proxy,server,appjs,Node.js,Proxy,Server,Appjs,我正在尝试让节点http代理与AppJS一起工作。不幸的是,它在应用程序启动时崩溃了。我所做的: 下载并从中提取AppJS 使用npm安装节点http代理安装http代理 编辑了app.js窗口。打开(创建)功能: window.on('create', function(){ console.log("Window Created"); window.frame.show(); window.frame.center(); window.frame.setMenuBar(menubar);
- 下载并从中提取AppJS李>
- 使用npm安装节点http代理安装http代理李>
- 编辑了app.js窗口。打开(创建)功能:
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); });
例如,如果我在家用电脑和工作时运行应用程序,我会将工作电脑的代理设置设置为homePC_IP:8000。这行得通吗?还没有解决节点http代理崩溃的问题,但我使用了,这很有魅力 你试过了吗?你有理由相信它不起作用吗?我试过了,当我用locahost:8080作为代理时,它起作用了。当我用我的手机在4G上设置Wifi热点并使用我的家庭IP:8080时,它不起作用,我在路由器上打开了端口8080和端口80。我是不是错过了一步?经过深思熟虑,我知道了上面的原因:)我用的是同一台设置了代理服务器的电脑。。。。但我仍然不明白为什么在添加启动节点http代理时AppJS会崩溃?这里提供的代码:确实有效,但不适用于https:(有人建议node http proxy出了什么问题?