Proxy Updated
diff --git a/xos/core/xoslib/ui_src/contentProvider/package.json b/xos/core/xoslib/ui_src/contentProvider/package.json
index 6c573a5..93e1687 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\" \"node proxy.js\"",
+ "start": "npm install && bower install; npm run wiredep; parallelshell \"npm run babel\" \"npm run browser\"",
"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,6 +16,7 @@
"devDependencies": {
"babel": "^5.8.29",
"browser-sync": "^2.9.11",
+ "cors": "^2.7.1",
"express": "^4.13.3",
"npm-watch": "0.0.1",
"parallelshell": "^2.0.0",
diff --git a/xos/core/xoslib/ui_src/contentProvider/proxy.js b/xos/core/xoslib/ui_src/contentProvider/proxy.js
index 813a340..b373435 100644
--- a/xos/core/xoslib/ui_src/contentProvider/proxy.js
+++ b/xos/core/xoslib/ui_src/contentProvider/proxy.js
@@ -1,25 +1,24 @@
var express = require('express');
var request = require('request');
+var cors = require('cors');
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(cors());
app.use('/', function(req, res) {
var url = apiServerHost + req.url;
- var nr = request(url, function(err, pres, body){
+ req.headers['X-CSRFToken'] = req.headers['x-csrftoken'];
+
+ var nr = request({url: url, headers: req.headers}, function(err, pres, body){
if(err){
console.log(err);
return res.send(err)
}
- res.send(pres);
+ res.status(pres.statusCode).send(JSON.parse(pres.body));
});
});
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 0f91f61..cca5945 100644
--- a/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js
+++ b/xos/core/xoslib/ui_src/contentProvider/src/.tmp/xosContentProvider.js
@@ -37,9 +37,9 @@
}).factory('SetCSRFToken', function ($cookies) {
return {
request: function request(_request) {
- if (_request.method !== 'GET') {
- _request.headers['X-CSRFToken'] = $cookies.get('csrftoken');
- }
+ // if(request.method !== 'GET') {
+ _request.headers['X-CSRFToken'] = $cookies.get('csrftoken');
+ // }
return _request;
}
};
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 8a8f270..5e6ed36 100644
--- a/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js
+++ b/xos/core/xoslib/ui_src/contentProvider/src/js/xosContentProvider.js
@@ -49,9 +49,9 @@
.factory('SetCSRFToken', function($cookies) {
return {
request: function(request) {
- if(request.method !== 'GET') {
+ // if(request.method !== 'GET') {
request.headers['X-CSRFToken'] = $cookies.get('csrftoken');
- }
+ // }
return request;
}
};