Connect

Subdomains

Populate the req.subdomains array.
For example "ferret.tobi.example.com"
would yield ['tobi', 'ferret'].

Source

module.exports = function(){
  return function subdomains(req, res, next){
    req.subdomains = req.headers.host
      .split('.')
      .slice(0, -2)
      .reverse();

    next();
  };
};