Skip to content

Allow POST requests in endpoint for ServerSideRender block component - #196

Closed
kienstra wants to merge 5 commits into
WordPress:masterfrom
kienstra:add/ssr-post
Closed

kienstra wants to merge 5 commits into
WordPress:masterfrom
kienstra:add/ssr-post

Conversation

@kienstra

Copy link
Copy Markdown

This allows a block's <ServerSideRender> component to make a POST request, in case the attributes are too big for a GET request.

There have been several cases where sending the attributes in the GET request URL causes an error:

WordPress/gutenberg#19935
WordPress/gutenberg#16396 (comment)
https://wordpress.org/support/topic/error-loading-block-the-response-is-not-a-valid-json-response-2/

This follows the suggestion in 2 of those issues to allow using POST for the block endpoint, in addition to GET.

Trac ticket: https://core.trac.wordpress.org/ticket/49680


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

In order to allow <ServerSideRender> components
to have a large attributes object,
ideally it could POST attributes instead of
making a GET request for them.
So add support for a POST request in this endpoint that
<ServerSideRender> uses.
Following the convention
of other test methods.
@kienstra

Copy link
Copy Markdown
Author

It doesn't look like the Travis failures are related to this PR, though maybe I missed something.

@kienstra

kienstra commented Mar 23, 2020 •

Copy link
Copy Markdown
Author

WordPress/gutenberg#21068 is what actually uses this PR's addition of POST to the allowed request types.

Instead of having attributes be the entire body,
they are now simply a property of the body.
The test didn't fail locally,
so this might not work.
@TimothyBJacobs

Copy link
Copy Markdown
Member

Merged in r47756, 5460e0d.

@kienstra

kienstra commented May 3, 2020

Copy link
Copy Markdown
Author

Nice, thanks so much!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants