How to get url after redirection by superagent

how does superagent get url after redirection

my previous idea was to set .redirects (0) , and then get the redirected url, by Location in the response header, but this failed

ask the great god what I should do


the encapsulation of 301 maxRetrie 302 and other status codes is one of the functional designs of superagent and other http modules. superagent will perform a recursive jump to maxRetrie when receiving 301Accord302 , so if you want to get the redirected url, you can use the native http module .

Request.prototype._pipeContinue = function(stream, options){
  this.req.once('response', res => {
    // redirect
    const redirect = isRedirect(res.statusCode);
    if (redirect && this._redirectsPP != this._maxRedirects) {
      return this._redirect(res)._pipeContinue(stream, options);
    }
    //...
  })
}
Menu