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

Allow setting the request method for Turbo Frame requests to avoid 414 Long URL errors #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ghiculescu
Copy link

Currently the request that a Turbo Frame makes to load a page is hardcoded to a GET request. We came across an edge case where HTTP 414s were being thrown due to a very large request URL, in a complex form that heavily uses frames with URLs to hold form state.

The general approach to handling 414s is to switch to a POST. This PR adds the ability to declaratively do that on the frame element:

<turbo-frame id="stuff" src="/my/url" method="post" params='{"required":true,"type":"string"}'></turbo-frame>

You need to provide:

  • method= "post"
  • params = Something that URLSearchParams can interpret: stringified JSON, or form params.

This will make a POST to /my/url, with the provided params in the POST body.

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

Successfully merging this pull request may close these issues.

1 participant