lib/npm-proxy.js
function onDecision(err, target) {
    //
    // If there was no target then this is a 404 by definition
    // even if it exists in the public registry because of a
    // potential whitelist.
    //
    if (err || !target) {
      return self.notFound(req, res, err || { message: 'Unknown pkg: ' + pkg });
    }

    // if X-Forwarded-Host is set, npm returns 404 {"error":"not_found","reason":"no_db_file"}
    if (req.headers["x-forwarded-host"]) delete req.headers["x-forwarded-host"];

    //
    // If we get a valid target then we can proxy to it
    //
    self.log.info('[decide] %s - %s %s %s %j', address, req.method, req.url, target.vhost || target.host || target.hostname, req.headers);

    self.emit('headers', req, req.headers, target);

    req.headers.host = target.vhost || target.host || target.hostname;
    proxy.web(req, res, {
      target: target.href
    });
  }
function onDecision(err, target) {
    //
    // If there was no target then this is a 404 by definition
    // even if it exists in the public registry because of a
    // potential whitelist.
    //
    if (err || !target) {
      return self.notFound(req, res, err || { message: 'Unknown pkg: ' + pkg });
    }

    // if X-Forwarded-Host is set, npm returns 404 {"error":"not_found","reason":"no_db_file"}
    if (req.headers["x-forwarded-host"]) delete req.headers["x-forwarded-host"];

    //
    // If we get a valid target then we can proxy to it
    //
    self.log.info('[decide] %s - %s %s %s %j', address, req.method, req.url, target.vhost || target.host || target.hostname, req.headers);

    self.emit('headers', req, req.headers, target);

    req.headers.host = target.vhost || target.host || target.hostname;
    proxy.web(req, res, {
      target: target.href
    });
  }
function onDecision ( err , target ) { // // If there was no target then this is a 404 by definition // even if it exists in the public registry because of a // potential whitelist. // if ( err || ! target ) { return self . notFound ( req , res , err || { message : 'Unknown pkg: ' + pkg } ) ; } // if X-Forwarded-Host is set, npm returns 404 {"error":"not_found","reason":"no_db_file"} if ( req . headers [ "x-forwarded-host" ] ) delete req . headers [ "x-forwarded-host" ] ; // // If we get a valid target then we can proxy to it // self . log . info ( '[decide] %s - %s %s %s %j' , address , req . method , req . url , target . vhost || target . host || target . hostname , req . headers ) ; self . emit ( 'headers' , req , req . headers , target ) ; req . headers . host = target . vhost || target . host || target . hostname ; proxy . web ( req , res , { target : target . href } ) ; }
Proxy or serve not found based on the decision
Proxy or serve not found based on the decision