blob: e8c38fadb222033bc0ca8320e0fb1f011a35e7c2 [file] [log] [blame]
const conf = require('./gulp.conf');
const httpProxy = require('http-proxy');
// TODO move the proxy config in a separate file and share with browsersync.dist.js
const proxy = httpProxy.createProxyServer({
target: 'http://xos.dev:9101'
});
proxy.on('error', function(error, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
});
console.error('[Proxy]', error);
});
module.exports = function () {
return {
server: {
baseDir: [
conf.paths.tmp,
conf.paths.src
],
middleware: function(req, res, next){
if (req.url.indexOf('xosapi') !== -1) {
proxy.web(req, res);
}
else{
next();
}
}
},
open: true
};
};