Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 3652e64

Browse files
committed
Forwards proxy requests
1 parent 7c31789 commit 3652e64

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

digexp-sp-server/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* specific language governing permissions and limitations under the License.
99
*/
1010
var express = require('express');
11+
var request = require('request');
1112
var path = require('path');
1213
var fs = require('fs');
1314

@@ -90,6 +91,14 @@ exports.start = function start(dir, port) {
9091

9192
console.log('server running at port ' + port + ' using root folder ' + dir);
9293

94+
app.get(/^\/wps\/proxy\/http/, function(req, resp) {
95+
var url = req.path.substring("/wps/proxy/".length);
96+
url = url.replace(/^https?/, function(match) {
97+
return match + ":/";
98+
});
99+
request.get(url).pipe(resp);
100+
});
101+
93102
// Special processing for HTML and JS files
94103
app.get(['/*.html', '/*.js'], function(req, res) {
95104
console.log('get ' + req.path);

digexp-sp-server/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"name" : "ScriptAppServer",
3-
"version" : "0.1.1",
2+
"name": "ScriptAppServer",
3+
"version": "0.1.2",
44
"main": "./index.js",
5-
"dependencies" : {
6-
"express" : ">=3.x"
5+
"dependencies": {
6+
"express": ">=3.x",
7+
"request": "^2.69.0"
78
}
8-
}
9+
}

0 commit comments

Comments
 (0)