Skip to content
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

Please allow rendering after successful POST form submissions #1297

Open
omitter opened this issue Aug 19, 2024 · 2 comments
Open

Please allow rendering after successful POST form submissions #1297

omitter opened this issue Aug 19, 2024 · 2 comments

Comments

@omitter
Copy link

omitter commented Aug 19, 2024

Currently Turbo ignores renders after a form submission, unless it is accompanied by a 4xx/5xx status code.

The reason for this is (afaik) that the URL could be reloaded by the user as a GET request, which could potentially result in a "page not found" error. Maybe there's even more to it?

But there are other valid reasons to have a POST request render rather than redirect, besides error handling!

For instance a confirmation screen for a booking should be submitted by POST, since I don't want the user to copy the URL and paste it later again. So the idea is a POST request, that renders a page with the confirmation details and a new form that will submit to the final booking page. Even more, if the form was to contain images, it wouldn't even be possible to use a GET request. Custom non-sharable preview pages with file uploads would be a similar use case.

So, could you maybe give us an option to disable the mustRedirect logic? You already have the code, but I can't find a way to disable the mustRedirect logic from the outside. Currently I have to a manual non-Turbo request for confirmation/preview screens, which defeats the idea of writing no JavaScript, or send an wrong status code, which makes log analysis harder and makes me feel really uncomfortable.

@4lllex
Copy link

4lllex commented Aug 24, 2024

you could render with status 201 as a workaround.

@omitter
Copy link
Author

omitter commented Aug 27, 2024

Oh, I didn't think of this. Currently they check only for =200, so >=201 works great.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants