express icon indicating copy to clipboard operation
express copied to clipboard

res.redirect(undefined) sends invalid Location: undefined header

Open BOXER78 opened this issue 3 weeks ago • 4 comments

Calling res.redirect(undefined) currently sends a 302 response with the header Location: undefined. While there is a deprecation warning printed to the console ("Provide a url argument"), the actual HTTP response is malformed because undefined is not a valid URL.

BOXER78 avatar Dec 03 '25 16:12 BOXER78

@efekrskl Please review my PR for this issue.

BOXER78 avatar Dec 05 '25 09:12 BOXER78

While it’s not a valid URL, we convert any argument to a string, which is why passing undefined is valid and will trigger a 302.

With the new deprecation, Express v6 is expected to throw an error based on the data type, although it’s still the developer’s responsibility to perform validations for their redirect.

Ref: https://github.com/expressjs/express/issues/6391

bjohansebas avatar Dec 11 '25 15:12 bjohansebas

Greetings @BOXER78 .. I am interested to work on the issue. Can you please assign me the same please. ThankYou.

DhanashreePetare avatar Dec 16 '25 13:12 DhanashreePetare

@BOXER78 I would like to work on this issue. Please assign this to me /assign

vishalgupta-02 avatar Dec 19 '25 08:12 vishalgupta-02