diff --git a/src/lib/api.js b/src/lib/api.js index e7d9fc012..84359c8ba 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -16,15 +16,19 @@ var urlParams = require('./url-params'); */ module.exports = function (opts, callback) { - defaultsDeep(opts, { + defaults(opts, { host: process.env.API_HOST, - headers: { - 'X-Requested-With': 'XMLHttpRequest' - }, + headers: {}, responseType: 'json', useCsrf: false }); + if (opts.host === '') { + defaults(opts.headers, { + 'X-Requested-With': 'XMLHttpRequest' + }); + } + opts.uri = opts.host + opts.uri; if (opts.params) {