Opened 3 years ago
Closed 3 years ago
#50241 closed defect (bug) (wontfix)
Cannot publish the post using Gutenberg after changing REST URL prefix
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.5 |
Component: | REST API | Keywords: | has-screenshots reporter-feedback close |
Focuses: | administration, rest-api | Cc: |
Description
When I change REST URL prefix to something different "my-api" for example, using "rest_url_prefix" filter hook then it breaks the Gutenberg post save functionality because Gutenberg uses default "wp-json" REST URL prefix for API interactions.
Possible solution: Use "rest_get_url_prefix()" function to get URL prefix instead of "wp-json".
Attachments (2)
Change History (7)
#2
@
3 years ago
Hi @TimothyBlynJacobs
Thank you for looking into this. I am using the following code to change the REST URL prefix:
add_filter( 'rest_url_prefix', 'custom_rest_url_prefix' ); function custom_rest_url_prefix( $prefix ) { return 'api'; }
It changes default "wp-json" prefix to "api"
#3
@
3 years ago
- Keywords close added
Where are you putting that code? Is it in any kind of conditional somewhere? I'm unable to replicate using that code.
#4
@
3 years ago
I am using this code in theme's functions.php file. I just retested and getting the same error.
#5
@
3 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
I am using this code in theme's functions.php file.
Ah, I think that would be the issue, that is too late in the setup process. Try creating a site specific plugin or using the Snippets plugin and including your same code there.
Hi @ibachal,
Could you share the code you are using to change the REST URL prefix? Gutenberg uses the
createRootURLMiddleware
to set the base URL of the REST API. The only hardcoded usages ofwp-json
I see in the repo are docs or test code.