if(req.url == '/data/get' || req.url == 'data/get') {
var post_data = querystring.stringify({
proc: 'getConfig'
});
console.log('post_data->',post_data)
var options = {
host: '192.168.1.246',
port:80,
path: '/data/get',
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Content-Length': post_data.length
}
};
var body = ''
var client_req = http.request(options, function(res) {
console.log("Got response: " + res.statusCode);
res.on('data',function(d){
body += d;
}).on('end', function(){
console.log(res.headers)
console.log(body)
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
})
client_req.write(post_data)
client_req.end();
}```
我需要使用服务器的地址(192.168.1.246),把 localhost/data/get转发给192.168.1.246/data/get