index.js
function redirect(ctx, url, status) {
  if (ctx.accepts('html', 'json') === 'json') {
    ctx.set('Location', url);
    ctx.status = 401;
    ctx.body = {
      error: '401 Unauthorized'
    };
    return;
  }
  return ctx.redirect(url, status);
}
function redirect(ctx, url, status) {
  if (ctx.accepts('html', 'json') === 'json') {
    ctx.set('Location', url);
    ctx.status = 401;
    ctx.body = {
      error: '401 Unauthorized'
    };
    return;
  }
  return ctx.redirect(url, status);
}
function redirect ( ctx , url , status ) { if ( ctx . accepts ( 'html' , 'json' ) === 'json' ) { ctx . set ( 'Location' , url ) ; ctx . status = 401 ; ctx . body = { error : '401 Unauthorized' } ; return ; } return ctx . redirect ( url , status ) ; }
Send redirect response.

@param  {Context} ctx
@param  {String} url, redirect URL
@param  {Number|String} status, response status code, default is `302`

@api public
Send redirect response .