[英]How to configure AppJS to work with node-http-proxy server
我正在嘗試讓node-http-proxy與AppJS一起使用。 不幸的是,它在啟動應用程序時崩潰。 我做了什么:
編輯了app.js window.on(create)函數:
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); });
當應用程序啟動時,我想啟動nodeJS代理服務器。 是否可以從外部PC連接到此代理服務器? (我知道我需要為此打開端口)
例如,如果我在家用PC上運行該應用程序,並且在工作中,我會將工作PC的代理設置設置為homePC_IP:8000。 這樣行嗎?
還沒有針對node-http-proxy崩潰的修復程序,但是我改為使用https://github.com/TooTallNate/proxy ,它的工作原理很吸引人!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.