Updated generator to read parent env config
diff --git a/views/ngXosViews/contentProvider/gulp/server.js b/views/ngXosViews/contentProvider/gulp/server.js
index 78c1620..0bc2bd3 100644
--- a/views/ngXosViews/contentProvider/gulp/server.js
+++ b/views/ngXosViews/contentProvider/gulp/server.js
@@ -10,18 +10,24 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var fs = require('fs');
+var path = require('path');
const environment = process.env.NODE_ENV;
-if (environment){
- var conf = require(`../env/${environment}.js`);
-}
-else{
- var conf = require('../env/default.js')
+if(!fs.existsSync(path.join(__dirname, `../../../env/${environment || 'default'}.js`))){
+ if(!environment){
+ throw new Error('You should define a default.js config in /views/env folder.');
+ }
+ else{
+ throw new Error(`Since you are loading a custom environment, you should define a ${environment}.js config in /views/env folder.`);
+ }
}
+var conf = require(path.join(__dirname, `../../../env/${environment || 'default'}.js`));
+
var proxy = httpProxy.createProxyServer({
- target: conf.host || 'http://0.0.0.0:9999'
+ target: conf.host
});
@@ -51,11 +57,8 @@
},
middleware: function(req, res, next){
if(
- // to be removed, deprecated API
- // req.url.indexOf('/xos/') !== -1 ||
- // req.url.indexOf('/xoslib/') !== -1 ||
- req.url.indexOf('/hpcapi/') !== -1 ||
- req.url.indexOf('/api/') !== -1
+ req.url.indexOf('/api/') !== -1 ||
+ req.url.indexOf('/hpcapi/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;