blob: e703aff6b32650cf1cf9b794af09627c6f7d98d7 [file] [log] [blame]
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| For up-to-date information about the options:
| http://www.browsersync.io/docs/options/
|
| There are more options than you see here, these are just the ones that are
| set internally. See the website for more info.
|
|
*/
var httpProxy = require('http-proxy');
var environment = process.env.NODE_ENV;
if (environment){
var conf = require(`./env/${environment}.js`);
}
else{
var conf = require('./env/default.js')
}
var proxy = httpProxy.createProxyServer({
target: conf.host || 'http://0.0.0.0:9999'
});
var onos_proxy = httpProxy.createProxyServer({
target: conf.onos_host || 'http://10.50.1.15:8181'
});
proxy.on('error', function(error, req, res) {
console.error('[Proxy]', error);
});
onos_proxy.on('error', function(error, req, res) {
console.error('[ONOS Proxy]', error);
});
module.exports = {
"files": [
'./src/**/*.css',
'./src/**/*.js',
'./src/**/*.json',
'./src/**/*.html',
'./src/**/*.jpg',
'./src/**/*.png',
'./src/**/*.gif'
],
"server": {
baseDir: './src',
//directory: true,
routes: {
'/rs/dashboard': './mocks/dashboard.json',
'/rs/bundle': './mocks/bundle.json',
'/rs/users': './mocks/users.json'
},
middleware: function(req, res, next){
if(
req.url.indexOf('/api/') !== -1 ||
req.url.indexOf('/xos/') !== -1 ||
req.url.indexOf('/xoslib/') !== -1 ||
req.url.indexOf('/hpcapi/') !== -1
){
if(req.headers['X-CSRFToken']){
req.headers['x-csrftoken'] = req.headers['x-csrftoken'];
req.headers.cookie = `xoscsrftoken=${req.headers['x-csrftoken']}; xossessionid=${req.headers['sessionid']}`;
}
proxy.web(req, res);
}
else if(req.url.indexOf('/onos/') !== -1){
onos_proxy.web(req, res);
}
else{
next();
}
}
},
"port": 3000,
"open": "local"
};