Feature: Site Middleware
#622 allows for middleware to be defined on a per-site or per-route basis. In your site's controller (siites/<SITE>/index.js
) simply export middleware for the whole site to use:
module.exports.middleware = [
(req, res, next) => {
console.log(req.headers);
next();
}
]
Or attach middleware to a specific route:
module.exports.routes = [
{
path: '/',
middleware: [
(req, res, next) => {
console.log(req.headers);
next();
}
]
]
Courtesy of @yuliyv 🎉