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

Do custom blocks not get added to the block-renderer/ api endpoint by default? #12057

Closed
mrpritchett opened this issue Nov 19, 2018 · 10 comments
Closed
Labels
Needs Technical Feedback Needs testing from a developer perspective. [Package] Server Side Render /packages/server-side-render [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@mrpritchett
Copy link

I'm trying to use ServerSideRender and hitting an issue where non of our custom blocks are being registered on the API endpoint for block-renderer/.

@catehstn catehstn added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Nov 19, 2018
@designsimply designsimply added the [Package] Server Side Render /packages/server-side-render label Nov 19, 2018
@designsimply designsimply added the Needs Technical Feedback Needs testing from a developer perspective. label Nov 27, 2018
@pojke
Copy link

pojke commented Jan 15, 2019

Subscribing to this. All of our blocks since WP 5.0.3 (that were using ServerSideRender) stopped working as the API is not registered.

On a side note, it gets a bit boring when you hear in August 2018 that there are no major changes to Gutenberg, join the boat, try to help the community just to hit the wall hard when the editor breaks backwards compatibility literally monthly 👎 #feelingLikeJoomla

@opensaurusrex
Copy link

opensaurusrex commented Jan 18, 2019

I keep getting: GET /wp-json/wp/v2/block-renderer/library-plugin/frontpage-releases?context=edit&_locale=user 404 (Not Found) in the console and the request content I get is: {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}

@designsimply
Copy link
Member

@mrpritchett, I tried researching this and the most recent pull request I could find about block registration with regard to the API is in #13693 which appears to be the first step towards making all core, and optionally plugin, blocks discoverable on the server. I am new to JavaScript and block development. I think 13693 might be the most relevant because when I read the RFC I noticed two bullet points in the proposal which look like they might be relevant to your question:

  • Building REST APIs to fetch the available block types
  • Building REST APIs to fetch block objects from posts

The "References" and "Previous attempts" sections in the RFC talk about previous explorations and those also look interesting.

May I ask whether the information in #13693 answers your question?

@mrpritchett
Copy link
Author

Sorry, lost track of my own issue. For our team, the issue was where our custom webpack setup was enqueueing the files and partially where they were being compiled (at runtime). We played with settings and config and eventually got it to work just fine.

@grappler
Copy link
Member

Adding a note here because I came here via Google trying to figure out why I was getting a rest_no_route.

The reason for me was that register_block_type() was only running when is_admin() was true.

@opensaurusrex
Copy link

The issue I was having seemed to be fixed with WP 5.1, so now the dynamic blocks are working again.

@shahalom
Copy link

The issue is still producing with wp-v5.3.x. I have mentioned detail code here ... https://stackoverflow.com/questions/59018433/serversiderender-components-producing-error-loading-block-no-route-was-found-m

Please add a detail note here so that many of us can read when google send us ... Thanks.

@mrpritchett
Copy link
Author

This ended up being a problem with where our custom blocks were hooked into, not an actual WP issue itself.

@shahalom
Copy link

This ended up being a problem with where our custom blocks were hooked into, not an actual WP issue itself.

Thank you for the reply, I hope it is not an issue of WP itself now. My block hook is in the right place and still seeing the error!

@leurdo
Copy link

leurdo commented Sep 14, 2020

Adding a note here because I came here via Google trying to figure out why I was getting a rest_no_route.

The reason for me was that register_block_type() was only running when is_admin() was true.

saved my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Technical Feedback Needs testing from a developer perspective. [Package] Server Side Render /packages/server-side-render [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

8 participants