• My main WordPress site is hosted at example.com while my wordpress installation is hosted at api.example.com.

    I had to do this since I wanted a React front end while still using the Rest API. It works really well even though I had to do some workarounds for my links to appear properly.

    Here’s the problem though, if I change the “Site Address (URL)” to https://example.com rather than https://api.example.com I’m not able to create, update or save drafts from WordPress’ admin panel.

    I keep getting the error Updating failed. Error message: The response is not a valid JSON response.

    I know the Gutenberg editor uses the Rest API to autosave changes and such, but I’m not sure why changing this setting would break it. Is it because my WordPress is installed on a subdomain rather than a subfolder?

    • This topic was modified 4 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    If https://example.com/ ends up serving your WP content, it ought to work for API requests as well. There’s something odd about how serving https://example.com/ requests is being handled. Maybe you could use .htaccess rewrite rules to redirect https://example.com/ API requests through https://api.example.com? Not ideal, but without knowing the root cause of the issue it’s all I can think of.

    Thread Starter creativiii

    (@creativiii)

    If https://example.com/ ends up serving your WP content

    Well yes, but also no. The front-end is running in react, so it’s got no connection with WordPress itself except for the fact it uses Wp’s API, so that’s probably why that’s not working.

    Maybe you could use .htaccess rewrite rules to redirect https://example.com/ API requests through https://api.example.com?

    Any idea how to go about doing this?

    • This reply was modified 4 years, 5 months ago by creativiii.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing site address URL breaks saving posts’ is closed to new replies.