Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions _includes/api/en/4x/res-location.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ res.location('http://example.com')
res.location('back')
```

{% include admonitions/note.html content="`'back'` was deprecated in 4.21.0, use `req.get('Referrer') || '/'` as an argument instead." %}

A `path` value of "back" has a special meaning, it refers to the URL specified in the `Referer` header of the request. If the `Referer` header was not specified, it refers to "/".

See also [Security best practices: Prevent open redirect
Expand Down
2 changes: 2 additions & 0 deletions _includes/api/en/4x/res-redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ defaulting to `/` when the referer is missing.
res.redirect('back')
```

{% include admonitions/note.html content="`back` redirect was deprecated in 4.21.0, use `req.get('Referrer') || '/'` as an argument instead." %}

See also [Security best practices: Prevent open redirect
vulnerabilities](http://expressjs.com/en/advanced/best-practice-security.html#prevent-open-redirects).
6 changes: 0 additions & 6 deletions _includes/api/en/5x/res-location.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ Sets the response `Location` HTTP header to the specified `path` parameter.
```js
res.location('/foo/bar')
res.location('http://example.com')
res.location('back')
```

A `path` value of "back" has a special meaning, it refers to the URL specified in the `Referer` header of the request. If the `Referer` header was not specified, it refers to "/".

See also [Security best practices: Prevent open redirect
vulnerabilities](http://expressjs.com/en/advanced/best-practice-security.html#prevent-open-redirects).

Comment on lines -13 to -15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this note was removed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep it—there's no reason to remove it. Also, we still need to add the reference to the new recommended option (see https://github.com/expressjs/expressjs.com/pull/1835/files#r1997311521).

<div class='doc-box doc-warn' markdown="1">
After encoding the URL, if not encoded already, Express passes the specified URL to the browser in the `Location` header,
without any validation.
Expand Down
7 changes: 0 additions & 7 deletions _includes/api/en/5x/res-redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,5 @@ Path-relative redirects are also possible. If you were on
res.redirect('..')
```

A `back` redirection redirects the request back to the [referer](http://en.wikipedia.org/wiki/HTTP_referer),
defaulting to `/` when the referer is missing.

```js
res.redirect('back')
```

Comment on lines -48 to -54
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about removing this, maybe the recommended option should be mentioned req.get('Referrer') || '/'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to 5x migration guide

See also [Security best practices: Prevent open redirect
vulnerabilities](http://expressjs.com/en/advanced/best-practice-security.html#prevent-open-redirects).