-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
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.
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.
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
POST
requests in<ServerSideRender>
to prevent an error when theattributes
object is too big.<ServerSideRender>
uses GET requests in apiFetch(), but they can fail when theattributes
object is too big:This uses @swissspidy's suggestion in #16396 (comment) to allow using
POST
requests for large attributes.It adds an optional prop
httpMethod
, and if it's'POST'
, it causes<ServerSideRender>
to makePOST
requests. 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 AllowPOST
requests in endpoint forServerSideRender
block component wordpress-develop#196, which was merged into 5.5checkout
this PR's branch and donpm install && npm run dev
plugins/
directory in order to test this PRhttpMethod
propattributes
object 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: