-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for json/text submissions #6570
Conversation
🦋 Changeset detectedLatest commit: df081e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (contentType && /\bapplication\/json\b/.test(contentType)) { | ||
init.headers = { "Content-Type": contentType }; | ||
init.body = JSON.stringify(await request.json()); | ||
} else if (contentType && /\btext\/plain\b/.test(contentType)) { | ||
init.headers = { "Content-Type": contentType }; | ||
init.body = await request.text(); | ||
} else if ( | ||
contentType && | ||
/\bapplication\/x-www-form-urlencoded\b/.test(contentType) | ||
) { | ||
init.body = new URLSearchParams(await request.text()); | ||
} else { | ||
init.body = await request.formData(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure we proxy the RR request over the wire to Remix with the correct content type and body
packages/remix-react/components.tsx
Outdated
@@ -1573,22 +1587,29 @@ function convertRouterFetcherToRemixFetcher( | |||
formMethod && | |||
formAction && | |||
formEncType && | |||
formData | |||
(formData || json || text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want both json !== undefined
&& text != null
here? This would block null and empty string JSON submission, and empty string text submissions. If the "json" value here is pre-encoded (a json string) that one is fine, but the text case I think would cause issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, this also uncovered a small bug in submitting null
/""
in RR that I fixed in remix-run/react-router#10625
@@ -63,7 +63,7 @@ | |||
"@octokit/graphql": "^4.8.0", | |||
"@octokit/plugin-paginate-rest": "^2.17.0", | |||
"@octokit/rest": "^18.12.0", | |||
"@playwright/test": "^1.28.1", | |||
"@playwright/test": "^1.35.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to latest playwright so headless chromium works properly for remix-run/react-router#9865. The 1.28 version was giving a false positive on the FormData
check - so it was throwing the exception (indicating it supported the submitter) but then new FormData(form, submitter)
wouldn't include the value. It works fine in our browser testing though so we're OK chalking it up to a headless issue for now and can look for more robust solutions if folks run into issues.
}) => { | ||
test.fail( | ||
Boolean(javaScriptEnabled), | ||
"<Form> doesn't serialize submit buttons correctly #4342" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does now!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Make required changes and add tests for the Remix portion of remix-run/react-router#10413 which adds support for
application/json
andtext/plain
submissionsNote: CI will fail until we can point this to a pre/experimental release of RR
Closes #4342