Proxying request
diff --git a/xos/core/xoslib/ui_src/contentProvider/package.json b/xos/core/xoslib/ui_src/contentProvider/package.json
index 8f1b8ef..6c573a5 100644
--- a/xos/core/xoslib/ui_src/contentProvider/package.json
+++ b/xos/core/xoslib/ui_src/contentProvider/package.json
@@ -5,7 +5,7 @@
"main": "index.html",
"scripts": {
"test": "karma start",
- "start": "bower install; npm run wiredep; parallelshell \"npm run babel\" \"npm run browser\"",
+ "start": "bower install; npm run wiredep; parallelshell \"npm run babel\" \"npm run browser\" \"node proxy.js\"",
"wiredep": "wiredep -s 'src/index.html'",
"babel": "babel 'src/js' -w -d 'src/.tmp'",
"browser": "browser-sync start --files 'src/.tmp/**/*.js,src/**/*.html,src/**/*.css' --server './src' --reload-delay 1000 --port 3000",
@@ -16,9 +16,10 @@
"devDependencies": {
"babel": "^5.8.29",
"browser-sync": "^2.9.11",
- "http-proxy": "^1.12.0",
+ "express": "^4.13.3",
"npm-watch": "0.0.1",
"parallelshell": "^2.0.0",
+ "request": "^2.65.0",
"wiredep": "^3.0.0-beta"
}
}
diff --git a/xos/core/xoslib/ui_src/contentProvider/proxy.js b/xos/core/xoslib/ui_src/contentProvider/proxy.js
index 8567838..813a340 100644
--- a/xos/core/xoslib/ui_src/contentProvider/proxy.js
+++ b/xos/core/xoslib/ui_src/contentProvider/proxy.js
@@ -1,5 +1,26 @@
-var http = require('http-proxy');
+var express = require('express');
+var request = require('request');
-http.createServer(function(req, res) {
- proxy.web(req, res, { target: 'http://localhost:9000' }).listen(3000);
-});
\ No newline at end of file
+var apiServerHost = 'http://0.0.0.0:9000';
+
+var app = express();
+
+app.use(function(req, res, next) {
+ res.header("Access-Control-Allow-Origin", "*");
+ res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
+ next();
+});
+
+app.use('/', function(req, res) {
+ var url = apiServerHost + req.url;
+
+ var nr = request(url, function(err, pres, body){
+ if(err){
+ console.log(err);
+ return res.send(err)
+ }
+ res.send(pres);
+ });
+});
+
+app.listen(process.env.PORT || 4000);
\ No newline at end of file
diff --git a/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js b/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js
index 6c45eef..0f91f61 100644
--- a/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js
+++ b/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js
@@ -43,8 +43,8 @@
return _request;
}
};
-}).constant('apiBaseUrl', 'http://localhost:9000').service('ContentProvider', function ($resource, apiBaseUrl) {
- return $resource(apiBaseUrl, '/hpcapi/contentproviders/:id/', { id: '@id' }, {
+}).constant('apiBaseUrl', 'http://localhost:4000').service('ContentProvider', function ($resource, apiBaseUrl) {
+ return $resource(apiBaseUrl + '/hpcapi/contentproviders/:id/', { id: '@id' }, {
'update': { method: 'PUT' }
});
}).service('ServiceProvider', function ($resource) {
diff --git a/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js b/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js
index 04b6a15..8a8f270 100644
--- a/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js
+++ b/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js
@@ -56,9 +56,9 @@
}
};
})
-.constant('apiBaseUrl', 'http://localhost:9000')
+.constant('apiBaseUrl', 'http://localhost:4000')
.service('ContentProvider', function($resource, apiBaseUrl) {
- return $resource(apiBaseUrl, '/hpcapi/contentproviders/:id/', {id: '@id'}, {
+ return $resource(apiBaseUrl + '/hpcapi/contentproviders/:id/', {id: '@id'}, {
'update': {method: 'PUT'}
});
})