Skip to content

Commit 77ada90

Browse files
authored
Deprecate "back" magic string in redirects (#5935)
1 parent 21df421 commit 77ada90

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

History.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* Deprecate `res.location("back")` and `res.redirect("back")` magic string
5+
16
4.20.0 / 2024-09-10
27
==========
38
* deps: serve-static@0.16.0

lib/response.js

+1
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ res.location = function location(url) {
916916

917917
// "back" is an alias for the referrer
918918
if (url === 'back') {
919+
deprecate('res.location("back"): use res.location(req.get("Referrer") || "/") and refer to https://dub.sh/security-redirect for best practices');
919920
loc = this.req.get('Referrer') || '/';
920921
} else {
921922
loc = String(url);

0 commit comments

Comments
 (0)