Skip to content
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

ServerSideRender results in "Request-URI Too Long" #43549

Closed
areoimiles opened this issue Aug 24, 2022 · 4 comments
Closed

ServerSideRender results in "Request-URI Too Long" #43549

areoimiles opened this issue Aug 24, 2022 · 4 comments
Labels
[Package] Server Side Render /packages/server-side-render

Comments

@areoimiles
Copy link

Description

I have created a block that is rendered server side. This block is quite customisable and therefore has a lot of attributes. This works fine until I change too many attributes at which point the block displays "This block has encountered an error..." when editing in the block editor.

It looks as though server side blocks are rendered via this url endpoint "/wp-json/wp/v2/block-renderer/block/name" and the attributes are appended to the end of it. This endpoint returns a "414 Request-URI Too Long" if too many attributes are added.

Obviously I can change my server settings to make this work but I don't want the users of my plugin to have to go through this process. Am I missing a simple way around this without having to change server settings?

I think a simple fix would be to make the request to "/wp-json/wp/v2/block-renderer/block/name" within the block editor a POST instead of GET, this way it wouldn't matter how many attributes are added.

Any help on this would be much appreciated.

Step-by-step reproduction instructions

Visit the "/wp-json/wp/v2/block-renderer/block/name?context=edit&attributes=" endpoint (change block/name for your own block), then add a really long string to the end of the attributes.

Screenshots, screen recording, code snippet

No response

Environment info

Using the latest versions of WordPress 6.0.1

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added the [Package] Server Side Render /packages/server-side-render label Aug 24, 2022
@Mamaduka
Copy link
Member

Related issue #33879.

@areoimiles
Copy link
Author

@Mamaduka I will close this issue and add to the existing one.

@Mamaduka
Copy link
Member

Thanks, @areoimiles.

Actually, I just remembered that you could change the HTTP method for the ServerSideRender component. See #21068.

<ServerSideRender
  httpMethod="POST"
/>

@areoimiles
Copy link
Author

Yep I think that will solve it for me, thanks @Mamaduka!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Server Side Render /packages/server-side-render
Projects
None yet
Development

No branches or pull requests

2 participants