-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.js
27 lines (24 loc) · 926 Bytes
/
proxy.js
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
var http = require('http');
//var request = require('request');
//var app = require('express'); // ???
var port = 9000;
//var port = process.env.VCAP_APP_PORT || 8080;
console.log ('the portnumber is: '+ port);
http.createServer(function(request, response, next) {
console.log ('request url: ' + request.url) ;
if (request.url.match("")) {
//if (request.headers.origin.match("/datamanagement/a/**")) {
var proxy = http.createClient(8080, "sanity");
request.headers['Authorization'] = 'Basic c3VwZXJ1c2VyOnN1c2Vy';
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.on('response', function (proxy_response) {
proxy_response.pipe(response);
response.writeHead(proxy_response.statusCode, proxy_response.headers);
console.log(proxy_response.statusCode);
});
request.pipe(proxy_request);
} else {
//next();
response.end("<OK>");
}
}).listen(port);