When redirecting after a POST to the GET representation of the resource it’s recommended to use the 303 status code (see here).
And while I can not speak about other HTTP clients, this best practice is being “enforced” by
hackney (and by extension a number of Elixir HTTP clients), who only follows 303 redirects after a POST when setting
Since the Phoenix generators favour the “redirect after POST” pattern I’ve wondered if Phoenix should respect this best practice. As of right now the generated code will redirect with a 302 after POST, which will not work when trying to follow redirects with
hackney (which is how I came across all this).
As I see it there are two options:
- the generators include
redirect/2looks at the request and sets 303 instead of 302 for POST and PUT requests (most likely no, because this would lose the body of “real” POST to POST redirects)
I would be happy to provide a PR for either solution, but I wanted the communities input on the matter.