Hello,
I set up this plugin for the backend and SPA with React for the front, and get an error below when I call an endpoint from the frontend; When I call the endpoint via Postman or Curl, it works with no error. I modified Access-Control-Allow-Origin value to * in class-wp-headless-rest-api-cors.php, http.php and rest-api.php but it produces the same error. Any advice would be grateful.
Access to fetch at ‘https://mydomain/wp-json/wp/v2/posts/7’ from origin ‘https://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
]]>Hey!
i’am working with your Plugin and i guess i found a bug within the wp_headless_gutenberg_data rest field.
Same block-data gets overwritten. For example with two core/paragraph blocks. only the last inserted Paragraph is reaching the endpoint ??
I took a quick look into the code and found on line 182 (class-wp-headless-rest-gutenberg-blocks
) $response_data – same blockName?
Greetings ??
]]>Sorry to bother you again with noob questions.
I updated the version of PHP and got the new version of your plugin and activated him.
For my surprise I can’t find anymore the admin menu…
Can you tell me if this is happening with you too?
]]>Sorry, but how I enable REST cleanup? Where I supposed to add “add_filter( ‘wp_headless_rest__enable_rest_cleanup’, ‘__return_true’ );” to enable that feature.
]]>I improved the code that remove endpoints because wasn’t removing the various sub rest api.
This is the code modified that I am using:
public function remove_endpoints( $endpoints ) {
$endpoints_to_remove = array(
'media',
'types',
'statuses',
'taxonomies',
'tags',
'users',
'comments',
'settings',
'themes',
'blocks',
'oembed',
'posts',
'pages',
'block-renderer',
'search',
'categories'
);
foreach ( $endpoints_to_remove as $endpoint ) {
$base_endpoint = "/wp/v2/{$endpoint}";
foreach ( $endpoints as $maybe_endpoint => $object ) {
if ( strpos( $maybe_endpoint, $base_endpoint ) !== false ) {
unset( $endpoints[ $maybe_endpoint ] );
}
}
}
return $endpoints;
}
In that way all the foreach are not required because search by the name and it is more fast.
]]>