Description
The response body of a redirect via the res.redirect()
method will be <p>${statuses.message[status]} Redirecting to <a href="${url}">${url}</a></p>
, which is invalid HTML without a DOCTYPE
and <title>
element.
In particular, the absence of a <title>
element is detrimental to the user.
RFC 9110, 15.4. Redirection 3xx, states that the user agent behavior when the Location
header field is set with status code 3xx is "the user agent MAY automatically redirect its request to the URI".
Note that it is MAY.
And in fact, depending on the user's environment, automatic redirection may not occur and the contents of the response body may be displayed on the screen.
In the old days, there was an option to disable redirects in Presto Opera's advanced settings.
Even now, when Android Firefox redirects to an app-linked URL with 3xx, the app is automatically launched, but the browser screen still displays the 3xx response body.
Therefore, it would be desirable to set the DOCTYPE
and <title>
element even for 3xx screens.
Improvement plan
Line 963 in 8368dc1
↓
body = '<!DOCTYPE html><title>' + statuses.message[status] + '</title><p>' + statuses.message[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>'