-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdev-server.js
49 lines (48 loc) · 1.93 KB
/
dev-server.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var url = require('url');
var proxy = require('proxy-middleware');
var connect = require('gulp-connect');
exports.run = function() {
connect.server({
root: ['.', 'examples'],
port: 8001,
livereload: true,
middleware: function(connect, o) {
var gsProxy = (function() {
var options = url.parse('https://mapstory.org/geoserver');
options.route = '/geoserver';
return proxy(options);
})();
var gsProxyLocal = (function() {
var options = url.parse('http://localhost:8080/geoserver');
options.route = '/gslocal';
return proxy(options);
})();
var gsProxyStoryscapes = (function() {
var options = url.parse('http://storyscapes.geointservices.io/geoserver');
options.route = '/gsstoryscapes';
return proxy(options);
})();
var mapsProxy = (function() {
var options = url.parse('https://mapstory.org/maps');
options.route = '/maps';
return proxy(options);
})();
var assetsProxy = (function() {
var options = url.parse('http://mapstory.dev.opengeo.org/mapstory-assets');
options.route = '/assets';
return proxy(options);
})();
var dynamicProxy = function(req, res, next) {
var parts = url.parse(req.url);
if (parts.pathname === '/proxy') {
var target = parts.search.replace('?url=', '');
var options = url.parse(target);
req.url = options.path;
return proxy(options)(req, res, next);
}
return next();
};
return [gsProxy, gsProxyLocal, gsProxyStoryscapes, mapsProxy, assetsProxy, dynamicProxy];
}
});
};