They are very similar in their description, but do much more. The easiest way to see the difference is to look at the source .
res.location just sets the response header. It does not set the response status code or does not close the response, so you can write the response body if you want, and you need to call res.end() yourself after.
res.redirect , on the other hand, sets the status to 302, sets the header (using res.location ) and sends a body with a good response, indicating that the user is being redirected, and displays a link if their browser does not automatically redirect them to any that is the reason.
loganfsmyth
source share