-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrouter.js
More file actions
30 lines (26 loc) · 775 Bytes
/
router.js
File metadata and controls
30 lines (26 loc) · 775 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
var express = require('express');
var path = require('path');
var proxy = require('http-proxy');
var config = require('./config');
var WCSproxy = proxy.createProxyServer({
auth: config.wcs.username + ':' + config.wcs.password,
changeOrigin: true,
secure: true,
target: config.wcs.url
});
// Use express's Router to catch all routes and handle them by sending the
// index path to the watcher.
var router = express.Router();
router.get('/geoserver*', function(req, res) {
WCSproxy.web(req, res);
});
router.get('/*', function(req, res, next) {
// Check for resource requests and redirect to the index file for them
if (path.extname(req.path).length > 0) {
next();
} else {
req.url = "/index.html";
next();
}
});
module.exports = router;