Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions docs/api/response.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,18 @@ ctx.redirect('/cart');
ctx.body = 'Redirecting to shopping cart';
```

### response.back(url)
### response.back([alt])

Redirect back to the URL in the `Referrer` header (only when it points to the
same host as the current request). When the `Referrer` header is missing, or
refers to a different host, redirects to `alt` instead, falling back to `/`
when `alt` is not provided.

```js
ctx.back();
ctx.back('/index.html');
```

Similar to `.redirect(url)`, but first checks the `referer` header to redirect.
This is new in v3 as `.redirect(url, alt)` removes the special case `url = 'back'` option.

### response.attachment([filename], [options])
Expand Down