Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 1 | const conf = require('./gulp.conf'); |
Matteo Scandolo | 98b5f5d | 2017-03-17 17:09:05 -0700 | [diff] [blame] | 2 | const proxy = require('./proxy').proxy; |
| 3 | const extensionsProxy = require('./proxy').extensionsProxy; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 4 | |
| 5 | module.exports = function () { |
| 6 | return { |
| 7 | server: { |
| 8 | baseDir: [ |
| 9 | conf.paths.tmp, |
| 10 | conf.paths.src |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 11 | ], |
| 12 | middleware: function(req, res, next){ |
Matteo Scandolo | 47c53fc | 2017-03-23 14:11:32 -0700 | [diff] [blame] | 13 | if (req.url.indexOf('xosapi') !== -1 || req.url.indexOf('socket.io') !== -1) { |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 14 | proxy.web(req, res); |
| 15 | } |
Matteo Scandolo | 47c53fc | 2017-03-23 14:11:32 -0700 | [diff] [blame] | 16 | else if (req.url.indexOf('extensions') !== -1) { |
| 17 | extensionsProxy.web(req, res); |
| 18 | } |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 19 | else{ |
| 20 | next(); |
| 21 | } |
| 22 | } |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 23 | }, |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 24 | open: true |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 25 | }; |
| 26 | }; |