You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dynamic Block: ServerSideRender not using POST method for attributes (max URL length limit reached using GET) #19935
Description
The problem is when using ServerSideRender component, the number of attributes are limited to the max URL length of 2048 characters. My Dynamic Block has more attributes than are able to be passed through the GET method with the ServerSideRender component. This is because the ServerSideRender component defaults to using the GET method with apiFetch instead of POST. I wasn't able to figure out how to use the POST method with the block-renderer.
In the edit admin, specify attributes for the block that will be longer than 2048 characters for the GET request to apiFetch (/wp-json/wp/v2/block-renderer/block/name)
See error in edit admin (ServerSideRender component): Error loading block: The response is not a valid JSON response.
However, when viewing the live page (or preview), the block is rendered how it should be with no limit on the number of attributes.
Expected behavior
The ServerSideRender component seems like it should use the POST method with apiFetch so that you can pass in as many attributes as you would like rather than being limited to the max URL query string length.
The block does not have any side effect so the API opted for GET request. But I agree that GET requests are very restrictive in terms of their size. @youknowriad any thoughts on suggesting the change to POST (in core)?
No strong concerns for me but I feel there should be a trac ticket discussed with the REST API team. I also assume we need to keep both for backward compat?
Activity
jorgefilipecosta commentedon Jan 30, 2020
The block does not have any side effect so the API opted for GET request. But I agree that GET requests are very restrictive in terms of their size.
@youknowriad any thoughts on suggesting the change to POST (in core)?
youknowriad commentedon Jan 30, 2020
No strong concerns for me but I feel there should be a trac ticket discussed with the REST API team. I also assume we need to keep both for backward compat?
metalandcoffee commentedon Oct 9, 2020
I'm wondering what the status on this is. I ran into this issue where once I've hit this limit - all the rest of my dynamic blocks stop working.

TimothyBJacobs commentedon Mar 31, 2021
This has been supported for some time.
ServerSideRenderaccepts anhttpMethodprop that can be used to switch to aPOSTrequest: https://github.com/WordPress/gutenberg/tree/trunk/packages/server-side-render