Fixing bug in  creation

Change-Id: Ie4059b197fecfd605c2ad8bda334a9d1d18285de
diff --git a/conf/app/app.config.production.js b/conf/app/app.config.production.js
index 8f5bd5a..cf92947 100644
--- a/conf/app/app.config.production.js
+++ b/conf/app/app.config.production.js
@@ -1,5 +1,5 @@
 angular.module('app')
   .constant('AppConfig', {
-    apiEndpoint: '/spa/api',
+    apiEndpoint: '/xosapi/v1',
     websocketClient: '/'
   });
diff --git a/conf/browsersync-dist.conf.js b/conf/browsersync-dist.conf.js
index cbefe1d..d80f1ef 100644
--- a/conf/browsersync-dist.conf.js
+++ b/conf/browsersync-dist.conf.js
@@ -1,4 +1,5 @@
 const conf = require('./gulp.conf');
+const proxy = require('./proxy');
 
 module.exports = function () {
   return {
@@ -6,10 +7,18 @@
       baseDir: [
         conf.paths.dist
       ],
+      middleware: function(req, res, next){
+        if (req.url.indexOf('xosapi') !== -1) {
+          proxy.web(req, res);
+        }
+        else{
+          next();
+        }
+      },
       routes: {
         "/spa": "./dist"
       }
     },
-    open: false
+    open: true
   };
 };
diff --git a/conf/browsersync.conf.js b/conf/browsersync.conf.js
index e8c38fa..dd7acd5 100644
--- a/conf/browsersync.conf.js
+++ b/conf/browsersync.conf.js
@@ -1,18 +1,5 @@
 const conf = require('./gulp.conf');
-const httpProxy = require('http-proxy');
-
-// TODO move the proxy config in a separate file and share with browsersync.dist.js
-
-const proxy = httpProxy.createProxyServer({
-  target: 'http://xos.dev:9101'
-});
-
-proxy.on('error', function(error, req, res) {
-  res.writeHead(500, {
-    'Content-Type': 'text/plain'
-  });
-  console.error('[Proxy]', error);
-});
+const proxy = require('./proxy');
 
 module.exports = function () {
   return {
diff --git a/conf/proxy.js b/conf/proxy.js
new file mode 100644
index 0000000..daec1a8
--- /dev/null
+++ b/conf/proxy.js
@@ -0,0 +1,14 @@
+const httpProxy = require('http-proxy');
+
+const proxy = httpProxy.createProxyServer({
+  target: 'http://xos.dev:9101'
+});
+
+proxy.on('error', function(error, req, res) {
+  res.writeHead(500, {
+    'Content-Type': 'text/plain'
+  });
+  console.error('[Proxy]', error);
+});
+
+module.exports = proxy;
\ No newline at end of file