# Fix block editor errors when site and home URLs differ

URL: https://wp24x7.com/gutenberg-block-editor-with-different-site-url-and-home-url/
Updated: 2026-11-29
Type: blog post

> The block editor shows Updating failed or Publishing failed when WordPress Address and Site Address are on different domains, because the editor's REST requests go to the wrong origin. The safest fix is one domain for both. If the split is intentional, a scoped rest_url filter limited to the admin points the editor at the domain you are logged in on.

## Key facts

- For: site owners and developers with split admin and site domains
- Symptom: Updating failed or Publishing failed in the block editor
- Cause: REST URL derived from Site Address, cookie belongs to the other domain
- Best fix: one domain for both addresses
- Workaround: rest_url filter limited to is_admin(), in a small plugin
- Before changing: back up and test on staging
- Help: WordPress development and support

The block editor says "Updating failed" or "Publishing failed", and the browser console shows blocked or failed requests to a different domain. **This happens when your WordPress Address and Site Address are on different domains, so the editor's REST requests go to the wrong origin. The safest fix is one domain for both. If that is not possible, change the REST URL used inside the admin only.**

Back up first, test on staging, and put code in a small plugin, not a parent theme.

> **Quick answer**
Use one domain for both addresses if you can. If you must keep them apart, rewrite the REST URL only inside the admin with the filter below.

## Which setting is which?

Under **Settings, General** you will see two fields:

| Field | Saved as | Function | Meaning |
|:--|:--|:--|:--|
| WordPress Address (URL) | `siteurl` | `site_url()` | Where core files and the admin live, for example `https://cms.example.com` |
| Site Address (URL) | `home` | `home_url()` | The public site, for example `https://www.example.com` |

Many tutorials mix up the two. Remember it as: WordPress Address is where you log in, Site Address is where visitors go. Headless setups, front-end frameworks and some agency builds use different domains on purpose.

## Why does the editor fail?

You open the admin on the WordPress Address domain. The editor builds its API calls from the REST URL, which WordPress derives from the **Site Address**. So a browser on `cms.example.com` tries to call `www.example.com/wp-json/...`. That is a cross-origin request. The login cookie belongs to the other domain, so authentication fails, and CORS rules may block the call outright. Saving, publishing, loading media and parts of the interface fail with generic errors.

To confirm, open your browser's DevTools, the **Network** tab, and look at the failing request. Its host will differ from the host in your address bar. You can also visit `/wp-json/` on both domains to see where the REST API actually answers.

## What are the fixes, in order of preference?

1. **Use one domain for both.** If the split is not required, set both addresses to the same value, or use a subdirectory install instead of a different domain. No code is needed, but take care: changing these settings can take the site offline if the new address is wrong. Take a backup and know how to set them in `wp-config.php` (`WP_HOME` and `WP_SITEURL`).
2. **Proxy `/wp-json` on the front domain** to the WordPress server, so the admin and the API share an origin. This is a server or CDN task.
3. **Rewrite the REST URL only in the admin**, as shown below.

_The editor calls the REST API on the wrong origin, so the cookie is not sent_

## What does the code fix look like?

```php
add_filter( 'rest_url', function ( $url ) {
	if ( ! is_admin() ) {
		return $url;
	}

	return str_replace( home_url(), site_url(), $url );
} );
```

When the request is for an admin screen, the REST root points at the same domain you are logged in on, so the editor's calls are same-origin and the cookie works. On the front end, and for other consumers of the API, the URL stays on the Site Address.

The older version of this tip rewrote the URL everywhere, which also changes the API address printed in your public pages and in `<link rel="https://api.w.org/">`. A headless front end that reads that address would then be pointed at the admin domain. Limiting it to `is_admin()` avoids that.

Two things to know:

- The editor often receives its API root from a preloaded value printed in the page, not only from this filter. If the change seems to do nothing, check for a plugin or theme that sets its own API settings.
- This filter only reaches code that calls `rest_url()` in PHP. Hard-coded API URLs in scripts are not affected.

Not every host and plugin combination has been tested, so verify on your own staging copy before using it on production, especially on multisite.

## Is there anything else to check?

| Check | What to look for |
|:--|:--|
| Permalinks | If `/wp-json/` returns 404, re-save **Settings, Permalinks**. The REST API needs pretty permalinks or the `?rest_route=` fallback |
| Mixed content | One address on `http` and the other on `https` causes blocked requests. Both should be `https` |
| Cookies | An unusual `COOKIE_DOMAIN` in `wp-config.php` can stop login cookies working. Remove it unless you need it |
| Security plugins and firewalls | Blocking REST requests, or Cloudflare rules challenging `/wp-json/`. See our [Cloudflare rules guide](/5-simple-rules-in-cloudflare-to-secure-your-wordpress-website) |
| Caching | REST responses cached for logged-in users can return stale data |
| CORS headers | Cookie authentication does not work across origins, so use application passwords or tokens for headless clients |

## How do I confirm the fix?

1. **Clear** the browser cache and the site's page cache.
2. **Open** a post in the editor on the admin domain.
3. **Make** a trivial change, press **Update**, and look for a green success notice.
4. **Check** the Network tab: the `wp/v2/posts/...` call should now go to the admin domain with a 200 status.
5. **Load** a public page and confirm the front end still works, and the API address printed in its source is unchanged.

## Why not "just" fix the settings?

Sometimes you can. If your setup has no reason for two domains, collapsing them is the lasting answer. When the split is intentional, as in a headless build, treat this filter as one piece of a design that also covers previews, media URLs, CORS and authentication. If that is the project you are on, our [WordPress development team](/wordpress-development) builds headless and split-domain setups properly, and our [support team](/wordpress-support) can debug the editor error for you. For other editor failures, see [how to debug errors in WordPress](/how-to-debug-error-in-wordpress).

**Editor still failing?**
A person will look at the actual requests and tell you what is wrong.
[Post a project](/post-project)
[Call the help desk](tel:+18043754450)

## Frequently asked questions

### Which URL is which in WordPress settings?

WordPress Address (siteurl, site_url()) is where WordPress core and the admin live. Site Address (home, home_url()) is the address visitors use. They are often the same, but they can differ.

### Does this affect sites with WordPress in a subdirectory?

Usually not. The problem appears when the two addresses are different domains or subdomains, because the editor makes requests across origins.

### Is there a fix without code?

Yes. Serve the admin and the site from the same domain, or use one domain for both settings. Code is the workaround when you must keep them separate.

### Why does the editor fail when the two addresses differ?

The editor builds API calls from the REST URL derived from the Site Address, so a browser on the admin domain calls the other domain. The login cookie belongs to the other domain, so authentication fails and CORS may block it.

### How can I confirm this is the cause?

Open DevTools, the Network tab, and compare the host of the failing request with the host in the address bar. You can also visit /wp-json/ on both domains to see where the REST API actually answers.

### Why limit the filter to is_admin()?

An older tip rewrote the URL everywhere, which also changes the API address printed in public pages and the api.w.org link. A headless front end reading that address would then point at the admin domain.

### Where should the filter code go?

In a small plugin, not a parent theme, so it survives a theme change. Back up and test on staging first, especially on multisite.

### The filter seems to do nothing. What should I check?

The editor often receives its API root from a preloaded value printed in the page. Check for a plugin or theme that sets its own API settings, and remember the filter only reaches code that calls rest_url() in PHP.

### What else can cause Updating failed?

Pretty permalinks needing a re-save if /wp-json/ returns 404, mixed http and https addresses, an unusual COOKIE_DOMAIN, security plugins or Cloudflare rules blocking /wp-json/ and cached REST responses for logged-in users.

### Can I set the addresses in wp-config.php?

Yes, with WP_HOME and WP_SITEURL. Take a backup first and know how to recover, because a wrong address can take the site offline.

### What if I deliberately use a headless setup?

Treat the filter as one piece of a design that also covers previews, media URLs, CORS and authentication. Cookie authentication does not work across origins, so use application passwords or another token approach for headless clients.

### How do I confirm the fix worked?

Clear browser and page caches, open a post on the admin domain, make a trivial change and press Update. The Network tab should show the wp/v2/posts call going to the admin domain with a 200 status, and the public front end should be unchanged.

### Who can fix this for me?

The WP24x7 support team can debug the editor error, and the development team builds headless and split-domain setups properly.
