Repository navigation
Prevent an error in <ServerSideRender> by allowing POST request - #21068
Conversation
There can be an issue if the attributes object is big, and the GET request fails and causes an error message in the block. This allows POSTing the attributes, preventing the error message. See the PR to Core supporting the POST request.
There are 2 failed e2e tests, though it doesn't look like they're caused by this PR.
|
The E2E test failures above don't look to be related to this PR, but maybe I missed something. |
Now, Core accepts POST requests, with the attributes in an array. WordPress/wordpress-develop@5460e0d
|
Now that WordPress/wordpress-develop@5460e0d was merged, this PR's dependency is satsfied. |
There was a failed e2e test: https://github.com/WordPress/gutenberg/pull/21068/checks?check_run_id=925354338#step:7:15 This doesn't look related to this PR, but I don't know
|
Hi @ocean90, Would you be able to review this, or point me to someone who could? The Core patch for this is merged. It now has the latest from Thanks, Dominik! |
As Pascal mentioned, it's easier to understand what this does.
ocean90
left a comment
There was a problem hiding this comment.
Would be good to document this change in CHANGELOG.md.
Commit Dominik's suggestion to only allow POST and GET requests Co-authored-by: Dominik Schilling <dominikschilling+git@gmail.com>
|
Hi @ocean90,
Good idea, the |
|
Was this patch not included in 5.5? |
|
@JohnRDOrazio No. As you can see this PR has not been merged yet. |
|
ok, is there a workaround I can use until it's merged? A filter I can use to use POST instead of GET for ServerSideRender? |
|
There's not really a workaround, other than forking this component. It'd be great if this could be merged, I really appreciate the reviews here. |
|
Thanks a lot for merging this! |
yes thank you for merging this, I have just updated the Gutenberg plugin on one of my websites, and I tested using |
|
Great to hear, thanks a lot for testing it! |
Description
Allows optionally using
POSTrequests in<ServerSideRender>to prevent an error when theattributesobject is too big.<ServerSideRender>uses GET requests in apiFetch(), but they can fail when theattributesobject is too big:This uses @swissspidy's suggestion in #16396 (comment) to allow using
POSTrequests for large attributes.It adds an optional prop
httpMethod, and if it's'POST', it causes<ServerSideRender>to makePOSTrequests. It's prevented errors in my testing.Also, it depends on WordPress/wordpress-develop#196.
Reported in:
#19935
#16396 (comment)
https://wordpress.org/support/topic/error-loading-block-the-response-is-not-a-valid-json-response-2/
How has this been tested?
wp core update --version=5.5-RC1# or any version 5.5+, as this depends on AllowPOSTrequests in endpoint forServerSideRenderblock component wordpress-develop#196, which was merged into 5.5checkoutthis PR's branch and donpm install && npm run devplugins/directory in order to test this PRhttpMethodpropattributesobject doesn't cause an error in the<ServerSideRender>component<ServerSideRender>looks good, like 'Archives', 'Latest Comments', and 'Latest Posts'Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: