diff --git a/README.md b/README.md index bd9bd8177f7706fdfd3807af58a8c6dd252e8bdd..8b671b6cfa430783077b81eaf90e0140cd1b9187 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ To get up and running: $ bower install $ open index.html -If your REST server expects a namespace on the URL path (such as `/api/study/list` instead of `/study/list`), add it to the `config/config.js`file. You can specify either a namespace (`/api/`) or a URL (`http://my-host:8080/api`). +If your REST server expects a namespace on the URL path (such as `/api/study/list` instead of `/study/list`), add it to the `config/config.js`file. You can specify either a namespace (`/api`) or a URL (`http://my-host:8080/api`). diff --git a/config/config.js b/config/config.js index 2f261002681bffa82e888aa9a4378e3e86ed3480..17240a3f3354311a65b5c11c01901b0432529469 100644 --- a/config/config.js +++ b/config/config.js @@ -1,8 +1,3 @@ -define(['dojo/_base/declare'], function(declare) { - return declare('nesstarconfig.config', null, { - - /* API URL namespace */ - baseUrl: '/api/' - - }); -}); \ No newline at end of file +window.config = { + baseUrl: '' +} \ No newline at end of file diff --git a/js/_RestMixin.js b/js/_RestMixin.js index 8baa1e03ddfcdca3007212125ea8721fbbed90df..848d71616917786a7b999764560787e7a69f7278 100644 --- a/js/_RestMixin.js +++ b/js/_RestMixin.js @@ -1,7 +1,7 @@ define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/request', - 'nesstarconfig/config'], function(declare, lang, request, config) { + 'nesstarconfig/config'], function(declare, lang, request) { return declare('nesstartouch._RestMixin', null, { defaultOptions: { method: 'GET', @@ -40,8 +40,12 @@ define(['dojo/_base/declare', }, addBaseUrl: function(originalUrl) { - if (config) { - return config.baseUrl + originalUrl; + if (window.config) { + var base = window.config.baseUrl; + if (base.indexOf('/', base.length - 1) !== -1) { + base = base.substring(0, base.length - 1); + } + return base + originalUrl; } return originalUrl; },