-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
307 redirects within actions do not result in a new POST request being made #4356
Comments
My current hack to make this work as I expected is to instead construct a response like this: throw new Response(null, {
status: 204,
headers: {
'Set-Cookie': cookie,
'x-three-zero-seven': 'true',
'Location': request.url,
},
}); And then have a export const handleDataRequest: HandleDataRequestFunction = (response: Response) => {
if (response.headers.has('x-three-zero-seven')) {
return new Response(response.body, {
status: 307,
headers: response.headers,
});
}
return response;
}; This works since the |
That's an odd status. It assumes the user-agent still has access to the originally posted data. |
Really interesting issue, thanks! |
Very interesting indeed!
I don't think this is a problem on our end, as we create the Based on this wording, it sounds like preserving the method is the right behavior in most but not all 3xx cases:
I'll do some deeper reading on that to be sure, but at a very quick glance it sounds like maybe 301/303 changing to a GET is ok, but 302/307/308 should preserve the method. Update: @machour is probably correct below that we shouldn't change 302 |
@brophdawg11 to continue the quote:
As far as I remember, I've never seen a 302 doing something other than GET. I'm not sure we should start preserving the method for 302, as it would break a lot of apps.. |
remix-run/react-router#9597 adds this 307/308 handling to react-router, and Remix should pick that up once we finish moving Remix onto React Router 6.4 |
We finished the above work in Remix 1.10.0 so this should be handled correctly now. I'm going to close this out but please re-open if you are still running into issues! |
What version of Remix are you using?
1.7.0
Steps to Reproduce
Inside an action, redirect with a 307 status code. For example:
Expected Behavior
The semantic meaning of 307 is
Therefore I expect the code above to be interpreted as
Actual Behavior
It makes a GET request to the URL associated to the action (the normal behaviour of a 302 redirect on the web)
The text was updated successfully, but these errors were encountered: