This can be easily done with a plugin.
Use the static:app.preload hook and add a middleware to the express object. Something like below.
myPlugin.onPreLoad = function(data, callback) {
data.app.use(function(req, res, next) {
if (req.path.startsWith('/') || req.path.startsWith('/api')) {
if (req.uid) {
helpers.redirect(res, '/recent');
} else {
helpers.redirect(res, '/categories');
}
} else {
next();
}
});
callback();
};