diff --git a/lib/cartodb/middleware/context/db-conn-setup.js b/lib/cartodb/middleware/context/db-conn-setup.js index 90b76818..dec48f6d 100644 --- a/lib/cartodb/middleware/context/db-conn-setup.js +++ b/lib/cartodb/middleware/context/db-conn-setup.js @@ -3,7 +3,6 @@ const _ = require('underscore'); module.exports = function dbConnSetupMiddleware(pgConnection) { return function dbConnSetup(req, res, next) { const user = res.locals.user; - pgConnection.setDBConn(user, res.locals, (err) => { if (err) { if (err.message && -1 !== err.message.indexOf('name not found')) { @@ -21,11 +20,11 @@ module.exports = function dbConnSetupMiddleware(pgConnection) { dbhost: global.environment.postgres.host, dbport: global.environment.postgres.port }); - - res.set('X-Served-By-DB-Host', req.params.dbhost); + + res.set('X-Served-By-DB-Host', res.locals.dbhost); req.profiler.done('req2params'); - + next(null); }); }; diff --git a/test/unit/cartodb/prepare-context.test.js b/test/unit/cartodb/prepare-context.test.js index fc8c9bd0..dbbfb8bf 100644 --- a/test/unit/cartodb/prepare-context.test.js +++ b/test/unit/cartodb/prepare-context.test.js @@ -127,7 +127,7 @@ describe('prepare-context', function() { } }; - res = {}; + res = { set: function () {} }; dbConnSetup(prepareRequest(req), prepareResponse(res), function() { // wrong key resets params to no user