express icon indicating copy to clipboard operation
express copied to clipboard

Cleaner way for redirecting back to the Referrer

Open ricordisamoa opened this issue 8 years ago • 7 comments

The 'back' special case has been moved from res.location() to a new req.back getter. In the future, this will make it possible to redirect to a regular 'back' page.

ricordisamoa avatar Jun 28 '15 00:06 ricordisamoa

As this is a breaking change, though small, I wouldn't mind issuing a deprecation warning and waiting for 5.x instead.

ricordisamoa avatar Jun 28 '15 00:06 ricordisamoa

Seems reasonable to me to remove the magic string value in 5.0

dougwilson avatar Jun 28 '15 01:06 dougwilson

Changed to emit deprecate() instead of breaking the current behavior.

ricordisamoa avatar Jun 28 '15 01:06 ricordisamoa

Any update?

ricordisamoa avatar Jul 28 '15 14:07 ricordisamoa

How is this any different than just res.redirect(req.get("referer")||"/")? The 'back' should just be removed as it is a feature that only aims to save keystrokes.


Sidenote: If we are to keep this I suggest adding a test or two for res.location separate from res.redirect.

gabeio avatar Jul 28 '15 15:07 gabeio

@dougwilson what should I do?

ricordisamoa avatar Oct 18 '15 21:10 ricordisamoa

I'm all for removing the magic string from Express 5.0, but yes, adding req.back is not a good replacement either, so what to replace it with needs to be thought on more.

dougwilson avatar Oct 18 '15 21:10 dougwilson