diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index 1a853bd9..7010afa6 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -87,7 +87,7 @@ LayergroupController.prototype.register = function(app) { `${basePath}/:token/:layer/:z/:x/:y.(:format)`, cors(), userMiddleware, - validateLayerRouteMiddleware, + validateLayerRoute(), this.prepareContext, this.getMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi), this.layer(this.tileBackend), @@ -244,12 +244,14 @@ LayergroupController.prototype.register = function(app) { ); }; -function validateLayerRouteMiddleware(req, res, next) { - if (req.params.token === 'static') { - return next('route'); - } +function validateLayerRoute () { + return function validateLayerRouteMiddleware(req, res, next) { + if (req.params.token === 'static') { + return next('route'); + } - next(); + next(); + }; } LayergroupController.prototype.analysisNodeStatus = function (analysisStatusBackend) {