Environment: Node.js, Express
Question: What is the correct status code for a situation in which a POST request successfully logs out a user and redirects the client to the home page?
Background: I use a POST request to log out clients. At the end of a successful log out I use,
return res.redirect('/') to forward the user to the home page.
When I checked the headers in Dev Tools I saw that Express was by default sending a 302 status code. However in my situation I’m not sure if that’s right because resources have not been moved temporarily or permanently. When an internal redirect happens due to the normal operation of a server what is the correct status code to send?
Request URL: https://www.example.com/logout
Request Method: POST
Status Code: 302
Remote Address: 184.108.40.206:443
Referrer Policy: strict-origin
Below in the response header it shows
It’s 303 – See other. The "resource" has not been moved because there is no resource to speak of – you’re displaying a related page, which is, however, not the representation of the hypothetical "logout resource".