-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (27 loc) · 710 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (27 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var http = require('http');
var proxy = http.createServer(function(req, res){
console.log(req.method);
options = {
host:"192.168.1.25",
port:"9999",
path:req.url,
method:req.method,
headers:{
"Content-type":"application/json; charset=utf-8"
}
};
var sreq = http.request(options, function(sres){
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Content-type", "application/json; charset=utf-8");
sres.pipe(res);
sres.on("end", function(){
// console.log("done");
})
});
if(/POSTIPUT/i.test(req.method)){
req.pipe(sreq);
}else{
sreq.end();
}
}).listen(9999);
console.log("server started on!");