You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering how to pass a model to middleware 404 and 500? The reason being that my templates need a bunch of dust variables (prod/dev, assets on different cdns, etc) which are all defined in config and passed to the relevant model. It's a single page app, so it's all good except for the error pages.
example :
router.get('*', function(req, res, next){
var env = req.app.kraken.get('env:env');
model.cloudfront = req.app.kraken.get('aws:cloudfront_URL');
model.version = req.app.kraken.get('version:current');
if (env === 'production') {
model.production = 1;
} else if (env === 'staging') {
model.staging = 1;
}
var maintenance = req.app.kraken.get('maintenanceMode:state');
if(maintenance){
model = new maintenanceModeModel();
console.log('maintenance Mode on');
res.render('maintenanceMode',model);
}else{
next();
}
});
Is there a way to pass an object to the default middleware, or do I have to make custom routes to handle the errors?
The text was updated successfully, but these errors were encountered:
404 and 500 middleware are already deprecated. See #359. You should be writing these error handlers as a standard practice (that will provide you more flexibility and control).
I was wondering how to pass a model to middleware 404 and 500? The reason being that my templates need a bunch of dust variables (prod/dev, assets on different cdns, etc) which are all defined in config and passed to the relevant model. It's a single page app, so it's all good except for the error pages.
example :
Is there a way to pass an object to the default middleware, or do I have to make custom routes to handle the errors?
The text was updated successfully, but these errors were encountered: