code: function patchRequestHost() {
    return function(req, res, next) {
      defineGetter(req, 'host', function host() {
        const trust = this.app.get('trust proxy fn');
        let val = this.get('X-Forwarded-Host');
  
        if (!val || !trust(this.connection.remoteAddress, 0)) {
          val = this.get('Host');
        }
  
        return val || undefined;
      });
  
      next();
    };
  }
docs: /*
  Apply a patch to req.host to fix a bug that exists in Express v4.
  
  Specifically, without this patch, req.host will only return the host _name_
  and not the full host including the port number.
  
  This patch currently exists in Express v5, which is also currently alpha.
  
  For more information, see:
  
  https://expressjs.com/en/guide/migrating-5.html#req.host
  https://github.com/expressjs/express/blob/4.16.4/lib/request.js#L448-L452
  https://github.com/expressjs/express/blob/5.0.0-alpha.7/lib/request.js#L395-L415