diff --git a/core/server/api/v2/settings-public.js b/core/server/api/v2/settings-public.js index 1ca2e6a9a4..79c413527e 100644 --- a/core/server/api/v2/settings-public.js +++ b/core/server/api/v2/settings-public.js @@ -1,4 +1,5 @@ const settingsCache = require('../../services/settings/cache'); +const urlUtils = require('../../lib/url-utils'); module.exports = { docName: 'settings', @@ -8,7 +9,9 @@ module.exports = { query() { // @TODO: decouple settings cache from API knowledge // The controller fetches models (or cached models) and the API frame for the target API version formats the response. - return settingsCache.getPublic(); + return Object.assign({}, settingsCache.getPublic(), { + url: urlUtils.urlFor('home', true) + }); } } }; diff --git a/core/test/acceptance/old/content/settings_spec.js b/core/test/acceptance/old/content/settings_spec.js index b1dee37029..9c8505b26f 100644 --- a/core/test/acceptance/old/content/settings_spec.js +++ b/core/test/acceptance/old/content/settings_spec.js @@ -43,7 +43,7 @@ describe('Settings Content API', function () { // Verify we have the right keys for settings settings.should.have.properties(_.values(publicSettings)); - Object.keys(settings).length.should.equal(22); + Object.keys(settings).length.should.equal(23); // Verify that we are returning the defaults for each value _.forEach(settings, (value, key) => { @@ -60,6 +60,12 @@ describe('Settings Content API', function () { return; } + // `url` does not come from the settings cache + if (key === 'url') { + should(value).eql(`${config.get('url')}/`); + return; + } + let defaultKey = _.findKey(publicSettings, v => v === key); let defaultValue = _.find(defaultSettings, setting => setting.key === defaultKey).defaultValue;