Changed Xos generator to use remote Apis trough proxy
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
index 8eab1bf..d5c5bf9 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
@@ -10,8 +10,12 @@
var httpProxy = require('http-proxy');
var del = require('del');
+if (process.env.NODE_ENV === 'cloudlab'){
+ var conf = require('../env/cloudlab.js');
+}
+
var proxy = httpProxy.createProxyServer({
- target: 'http://0.0.0.0:9999'
+ target: conf.host || 'http://0.0.0.0:9999'
});
@@ -49,6 +53,10 @@
req.url.indexOf('/xoslib/') !== -1 ||
req.url.indexOf('/hpcapi/') !== -1
){
+ if(conf.xoscsrftoken && conf.xossessionid){
+ req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
+ req.headers['x-csrftoken'] = conf.xoscsrftoken;
+ }
proxy.web(req, res);
}
else{
@@ -130,4 +138,4 @@
['browser']
);
});
-};
\ No newline at end of file
+};
diff --git a/xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js b/xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js
index 51f4918..283e90d 100644
--- a/xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js
+++ b/xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js
@@ -5,7 +5,7 @@
.module('xos.helpers')
.factory('SetCSRFToken', setCSRFToken);
- function setCSRFToken($cookies) {
+ function setCSRFToken($cookies) {
return {
request: function(request){
if(request.method !== 'GET'){
@@ -15,4 +15,4 @@
}
};
}
-})();
\ No newline at end of file
+})();