[Fixed] REST API wp-json returns 403 when using web story templates
-
Just posting here to help others. I just had a long night debugging this so hopefully it won’t happen to you too ??
We installed the web stories plugin in our staging server. During testing, when creating one from template [Stories -> Explore Templates -> (Choose any and click Use Template)], the UI shows “Unable to create story from template”. This does not happen when running in a local environment.
Chrome dev console shows that the REST API returns a list of posts but with a status code of 403 Forbidden. I inspected the request payload and it is a huge raw HTML content.
I couldn’t find where in WordPress this 403 is thrown because we all know WordPress has wonderful logging /s
Disabled all plugins except Web Stories, 403 still happens.
Put a die(“asdsadsadsad”) in the first line of public_html/index.php, 403 still happens but this time the REST call returns “asdsadsadsad” (I did not refresh the page)!
In short the error is in the server itself. Looked at apache logs, and there it is. The server is blocking the huge request payload through Rule 390707.
Increasing this value from 4k to 128k fixed it for me (the template payload was ~94k).
Another rule was triggered because of the “hidden” tags in the payload: 300076. It’s up to you whether you want to disable this or modify the pattern. I just decided to disable it (although I don’t recommend doing so)
If you are on a hosting service that has WHM, this is an easy thing to do.
If you are on shared hosting, it might be more difficult to ask this from your host.
- The topic ‘[Fixed] REST API wp-json returns 403 when using web story templates’ is closed to new replies.