Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#49146 closed defect (bug) (duplicate)

Corrupted inner REST API requests.

Reported by: vavra7's profile vavra7 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: needs-patch
Focuses: rest-api Cc:


1) Make clean installation of WordPress on (just example domain - can be random)
2) Go to Settings -> General and change field "Site Address (URL)" to value "". Hit "Save Changes".
3) Go to Pages -> Sample Page make a random change and hit "Update"

Reason is that WordPress internal request leads to wrong address:

Expected is request pointing to:

Wordpress is using "siteurl" domain instead of "home" domain for composing inner REST API request.

Change History (5)

#1 @TimothyBlynJacobs
5 years ago

  • Component changed from General to REST API
  • Focuses accessibility administration removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Severity changed from critical to normal
  • Status changed from new to closed
  • Version changed from 5.3.2 to 4.4

Duplicate of #37020.

Hello @vavra7, welcome to trac!

This is actually intentional behavior. If you need to change this, you can use the rest_url filter in get_rest_url.

See #42869, #46246

#2 @kosso
4 years ago

I have arrived here after having the same issue since we stopped using a 'Classic Editor' plugin and switched to Gutenberg Blocks.

I see the OP mentions "Wordpress is using the site_url host instead of the home host for composing inner REST API requests."

The way I see it is the other way around. Surely?

I thought site_url was the WordPress installation and home was the (or can be a) decoupled site on another domain, being fed by the REST API? Am I wrong?

eg: is my Wordpress install. is a 'decoupled' Angular site.

If I change site_url to , then wp-admin 'breaks', with errors caused by styles and scripts being loaded from the wrong domain. (eg: jQuery) ie: the decoupled one.

Also with this example, if I put in the home option field, my permalinks will also be pointing to the wrong (WP install) host too.

Running Wordpress 5.3.2.

Any info or pointers would be great thanks.

Last edited 4 years ago by kosso (previous) (diff)

#3 @isuke01
4 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Yes Facing same issue.
I have used WP core files inside wordpress directory so page backend is:


I have tried to use

add_filter( 'rest_url', 'fix_rest_url');
function fix_rest_url( $url ) {
    return $url;

but this actually return correct url

Last edited 4 years ago by isuke01 (previous) (diff)

#4 @danielamof
4 years ago

Put this code at the end of functions.php, in your active theme. It works like a charm :) Thanks to Kelderic for the solution:

add_filter('rest_url', function($url) {
    $url = str_replace(home_url(), site_url().'/index.php', $url);
    return $url;

#5 @TimothyBlynJacobs
4 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #37020.

Reclosing. Using the rest_url filter to adjust this for your particular setup is the recommended way to change this like how @danielamof has done.

Note: See TracTickets for help on using tickets.