lib/middleware/website.js
function redirect(url) {
  // unset headers
  const { res } = this;
  res
    .getHeaderNames()
    .filter(name => !name.match(/^access-control-|vary|x-amz-/i))
    .forEach(name => res.removeHeader(name));

  this.set("Location", url);

  // status
  if (!statuses.redirect[this.status]) this.status = 302;

  if (this.status === 302) {
    const redirect = new S3Error("Found", "Resource Found");
    redirect.description = "302 Moved Temporarily";
    this.body = redirect.toHTML();
    this.type = "text/html";
  } else {
    this.body = "";
    this.type = "";
  }
}
function redirect(url) {
  // unset headers
  const { res } = this;
  res
    .getHeaderNames()
    .filter(name => !name.match(/^access-control-|vary|x-amz-/i))
    .forEach(name => res.removeHeader(name));

  this.set("Location", url);

  // status
  if (!statuses.redirect[this.status]) this.status = 302;

  if (this.status === 302) {
    const redirect = new S3Error("Found", "Resource Found");
    redirect.description = "302 Moved Temporarily";
    this.body = redirect.toHTML();
    this.type = "text/html";
  } else {
    this.body = "";
    this.type = "";
  }
}
function redirect ( url ) { // unset headers const { res } = this ; res . getHeaderNames ( ) . filter ( name => ! name . match ( / ^access-control-|vary|x-amz- / i ) ) . forEach ( name => res . removeHeader ( name ) ) ; this . set ( "Location" , url ) ; // status if ( ! statuses . redirect [ this . status ] ) this . status = 302 ; if ( this . status === 302 ) { const redirect = new S3Error ( "Found" , "Resource Found" ) ; redirect . description = "302 Moved Temporarily" ; this . body = redirect . toHTML ( ) ; this . type = "text/html" ; } else { this . body = "" ; this . type = "" ; } }
Overrides Koa's redirect behavior with one more closely matching S3

@param {string} url
Overrides Koa s redirect behavior with one more closely matching S3