fix(ui): send JSON body as application/json when no file upload is present (Fixes #17777) - #17783
Open
waterWang wants to merge 2 commits into
Open
fix(ui): send JSON body as application/json when no file upload is present (Fixes #17777)#17783waterWang wants to merge 2 commits into
waterWang wants to merge 2 commits into
Conversation
waterWang
requested review from
AlessioGr,
JarrodMFlesch and
jacobsfletch
as code owners
August 14, 2026 04:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #17777 — The admin panel unconditionally sends all PATCH/POST requests (save, autosave, publish, save draft) as
multipart/form-data, even when the request payload contains only JSON data and no file is being uploaded.Per HTTP semantics,
multipart/form-datais intended for requests that include binary file data. When the payload is purely JSON, the request should useapplication/json. Sending JSON-only data wrapped in multipart encoding triggers false positives in standard WAF configurations (e.g., Cloudflare Enterprise).Changes
packages/ui/src/forms/Form/index.tsx:createFormData: When no file is present in the form data, return the JSON body directly as a string instead of wrapping it inFormDatawithserialize()fromobject-to-formdatasubmit: Detect whether the body isFormData(file upload) or a string (JSON), and setContent-Type: application/jsonheader when sending JSONpackages/ui/src/forms/Form/types.ts:CreateFormDatareturn type toFormData | string | Promise<FormData | string>FormPropsaction callback type to acceptFormData | stringVerified behavior
application/jsonto the same endpoint: 200 OKmultipart/form-datato the same endpoint: 403 blocked by WAF (Cloudflare Enterprise rule 6179ae15870a4bb7b2d480d4843b323c)application/jsonwhen no file is present, bypassing the WAF false positivemultipart/form-dataas before (unaffected)