blob: 3f262baefc219e8429985fc47a90451ab208395e [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001const conf = require('./gulp.conf');
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -07002const proxy = require('./proxy').proxy;
3const extensionsProxy = require('./proxy').extensionsProxy;
Matteo Scandoloe015fa92017-05-10 09:52:36 -07004const socketProxy = require('./proxy').socketProxy;
Matteo Scandolod819c922016-12-02 14:06:14 -08005
6module.exports = function () {
7 return {
8 server: {
9 baseDir: [
10 conf.paths.tmp,
11 conf.paths.src
Matteo Scandolo1aee1982017-02-17 08:33:23 -080012 ],
13 middleware: function(req, res, next){
Matteo Scandoloe015fa92017-05-10 09:52:36 -070014 if (req.url.indexOf('xosapi') !== -1) {
Matteo Scandolo1aee1982017-02-17 08:33:23 -080015 proxy.web(req, res);
16 }
Matteo Scandoloe015fa92017-05-10 09:52:36 -070017 else if (req.url.indexOf('socket.io') !== -1) {
18 socketProxy.web(req, res);
19 }
Matteo Scandolo47c53fc2017-03-23 14:11:32 -070020 else if (req.url.indexOf('extensions') !== -1) {
21 extensionsProxy.web(req, res);
22 }
Matteo Scandolo1aee1982017-02-17 08:33:23 -080023 else{
24 next();
25 }
26 }
Matteo Scandolod819c922016-12-02 14:06:14 -080027 },
Matteo Scandolo1aee1982017-02-17 08:33:23 -080028 open: true
Matteo Scandolod819c922016-12-02 14:06:14 -080029 };
30};