Skip to content

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

Closed

Description

@areoimiles

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

Activity

  1. added
    [Package] Server Side Render
    on Aug 24, 2022
  2. Mamaduka commented on Aug 24, 2022

    @Mamaduka
    Member

    Related issue #33879.

  3. areoimiles commented on Aug 24, 2022

    @areoimiles
    Author

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

  4. Mamaduka commented on Aug 24, 2022

    @Mamaduka
    Member

    Thanks, @areoimiles.

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

    <ServerSideRender
      httpMethod="POST"
    />
    
  5. areoimiles commented on Aug 24, 2022

    @areoimiles
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Package] Server Side Render

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions