-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy2yahoo.js
More file actions
33 lines (27 loc) · 892 Bytes
/
proxy2yahoo.js
File metadata and controls
33 lines (27 loc) · 892 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
29
30
31
32
33
var __dirname="www";
var express = require('express'),
app = express(),
httpProxy = require('http-proxy');
app.use(express.bodyParser());
//app.listen(process.env.PORT || 9000);
app.listen(9000);
var proxy = new httpProxy.RoutingProxy();
app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
app.get('/js/*', function(req, res) {
res.sendfile(__dirname + req.url);
});
app.get('/css/*', function(req, res) {
res.sendfile(__dirname + req.url);
});
app.all('/*', function(req, res) {
//req.url = 'v1/public/yql?q=show%20tables&format=json&callback=';
proxy.proxyRequest(req, res, {
//host: 'query.yahooapis.com', //yahoo is just an example to verify its not the apis fault
host: 'localhost', //yahoo is just an example to verify its not the apis fault
port: 80
});
console.log(req);
console.log(res);
});