Archived topic
Dreaded response is not a valid JSON response error - can't update Block Editor
8 replies · Started by Kip on December 26, 2022
I am trying to create Elements in the Block Editor, but keep running into a strict-origin-when-cross-origin error (Updating failed: the response is not a valid JSON response). I was able to create a Block Element (site footer), but am now unable to edit it. I have tried resetting permalinks (multiple times, including setting to Plain and saving, and then setting back), I tried this via Cloudflare https://community.cloudflare.com/t/wordpress-and-gutenberg-issue-with-wp-json-wp-v2-that-gives-403/341227 - creating a firewall rule for wp-json (didn't work), tried logging out and back in again, but nothing seems to work.
I need to be able to make this work, I have a new theme ready to deploy, everything works fine in a test server that is on the same server (Azure VM - Ubuntu 22.02 / PHP 8.1 / Nginx ).
I Inspected the page when I received a JSON error, and copy pasted the response in the Private Information below.
Please help.
Hi there,
Is the issue only occurring in a block element?
Does the editor works correctly in when editing a normal page or post?
Yes that's correct. I can switch the Block Element to "classic editor" and make changes, for example to the font color on a Headline. Switching back to the Block Editor after I make and save a change results in another failed json response error however. I was also able to make and save an edit in a normal post in the Block Editor without problems (we 99% use the Classic Editor, we're trying to move off of WP Show Posts which is why we're using the Block Editor).
I can switch the Block Element to “classic editor” and make changes
The block element is not supposed to be used like that and it's not designed to be used like that - it is supposed be used as in the Gutenberg editor only.
If you need to use the classic editor or have the classic editor plugin installed then you would need to use the hook element:
https://docs.generatepress.com/article/hooks-element-overview/
If your site isn't using block then I wouldn't recommend using GenerateBlocks and the Query loop block.
I only switched to the Classic Editor to see if I could get an edit to save, as I couldn't using the Block Editor. However, I'm trying to build these Elements while still using our current theme, which does largely use Classic Editor Elements. Are you saying that this is the reason why the Block Element is failing?
We have not had other reports on this so would need to go through the proper debugging steps to get to the bottom of this.
Do you have a staging site set up?
If so can you try disabling all plugins except GP Premium and GenerateBlocks to test first?
I have a staging site on the same server, same Ubuntu/PHP etc (all the latest stable), but using a different theme. The Block Element is a direct copy (that is, I created a new Block Element > Site Footer and set it up the same as on the staging server) of one on the staging server, which works fine.
I am going to try some more stuff, including this https://generatepress.com/forums/topic/updating-failed-the-response-is-not-a-valid-json-response/ - I added wp-json/wp/v2 to the Cloudflare allow list but not gp_elements, will try that.
fwiw it looks to me like you've had numerous other reports of this https://generatepress.com/forums/search/response+is+not+a+valid+json+response/#post-2474224, but as I don't have time right now I will dig in more tomorrow.
Thanks so far!
Yes - we've had some similar reports on this before but I don't believe any of them end up being a GP problem.
Let us know when you are ready to debug!
Hey sorry I thought I already replied to this, but I was able to add the /wp-json/v2/gp_elements/ to the Cloudflare firewall https://community.cloudflare.com/t/firewall-blocking-wp-editor-updates/158089/3 and this apparently solved the problem, as I am now able to edit the blocks.
I do not understand the workings of GP and/or WordPress enough to make decisions on whether this is or is not a GP problem, but I don't think this is a problem with Cloudflare as they're trying to protect my site. Somehow these calls to wp-json should be handled so that they don't trip up firewalls, no?
Anyway, you can close the ticket.
