137
|
1 |
/*jshint node:true*/ |
|
2 |
var proxyPath = '/proxy/bnf-sparql'; |
|
3 |
|
|
4 |
module.exports = function(app) { |
|
5 |
// For options, see: |
|
6 |
// https://github.com/nodejitsu/node-http-proxy |
|
7 |
var proxy = require('http-proxy').createProxyServer({}); |
|
8 |
|
|
9 |
proxy.on('error', function(err, req) { |
|
10 |
console.error(err, req.url); |
|
11 |
}); |
|
12 |
|
|
13 |
app.use(proxyPath, function(req, res, next){ |
|
14 |
// include root path in proxied request |
|
15 |
//req.url = proxyPath + '/' + req.url; |
|
16 |
req.url = req.url.slice(1); |
|
17 |
proxy.web(req, res, { target: 'http://data.bnf.fr/sparql' }); |
|
18 |
}); |
|
19 |
}; |