Roots Discourse

The REST API did not behave correctly

Anyone run into this one?

Under my Site Health Status it’s recommending I address the REST API:

The REST API did not process the context query parameter correctly.

I’ve been using Trellis for years and I’ve noticed this message show up under the WP Site Health Status before, but it never seemed to have a real impact on my site. Until now, that is.

Since upgrading my Migrate DB Pro plugin from Deliciousbrains to v2, it’s started reporting problems with the WP REST API as well, so clearly something is not right somewhere. This alert shows up across all my instances: dev, staging, and live, so at least it’s consistent. :sweat_smile:

I doubt this is directly Trellis-related since I can’t find any mention of it in these forums, but if anyone else has run into this issue I’d love to hear your thoughts.

Trellis 1.4.0
PHP 7.4
Ansible 2.8.20
Vagrant 2.2.10

Turns out this was due to some old custom-defined NGINX location blocks screwing things up. Specifically, there was a location block using a regex pattern to apply a trailing slash to urls without one. Not only was this messing with the REST API, but it was redundant since I’m pretty sure Trellis already handles this by default.

Removing the offending block from my rewrites.conf.j2 template and re-provisioning was all it took to make the Site Health report happy, and Migrate DB Pro is working as expected now. If any other Trellis users run into REST API errors, reviewing any custom NGINX blocks might be a good place to start.