WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.35k stars 4.13k forks source link

Problems when you define a site_url that is different from the home_url #54454

Open miscs opened 1 year ago

miscs commented 1 year ago

Description

I use WordPress in a headless mode and therefore I define a site_url that is different from the home_url in Settings->General.

home_url: backend.domainA.com site_url: domainB.com

If have seen https://github.com/WordPress/gutenberg/issues/1761 and implemented the mentioned workaround

add_filter('rest_url', function($url) {
    $url = str_replace(home_url(), site_url(), $url);
    return $url;
});

With this filter I can use Gutenberg again (add / edit posts). But when I use a block theme, I see the following call to the site_url, which obviously cannot work:

site_url/?p=10&_wp-find-template=true&_locale=user

Step-by-step reproduction instructions

  1. Go to Settings->General
  2. Define a site_url which is different from home_url
  3. Wonder why this is not supported by Gutenberg and implement the workaround in https://github.com/WordPress/gutenberg/issues/1761 using the rest_url-filter
  4. Open Gutenberg and check console -> there are errors logged because of a request to site_url/?p=10&_wp-find-template=true&_locale=user

Disclaimer: I want to use a block theme in the backend because of the functionality it provides in wp-admin, even when I am using WordPress in Headless mode with a custom frontend.

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

github-actions[bot] commented 11 months ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

miscs commented 11 months ago

It is still relevant with latest release.

github-actions[bot] commented 10 months ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

dz0ny commented 3 months ago

Here is a partial solution.

https://github.com/WordPress/gutenberg/issues/57945#issuecomment-2018234879