Open iamgabrielma opened 2 days ago
Related conversation: p1731567884525159-slack-CDLH4C1UZ
I think it could be useful to p2 about this on +jetpackvulcan, with an example of how one can make a request to wc/v3/products
when not using the Jetpack plugin, and when using the Jetpack plugin (or is it not dependent on the Jetpack plugin but instead depends on the connection to WordPress.com via the Jetpack Connection package that ships with the WooCommerce plugin?).
Impacted plugin
Jetpack
What
Add support for retrieving
X-WP-Total
andX-WP-TotalPages
for Jetpack-tunnelled requests.How
Some Woo core endpoints include useful data in the response headers, for example
X-WP-Total
andX-WP-TotalPages
which we can use for pagination. However, when using a Jetpack-tunnelled request, these headers are removed from the response.As specific example for the WooCommerce app, when we make a request to
wc/v3/products
the response includes aX-WP-Total
header that tells us how many total results are for a query regardless of the value ofper_page
that we submit, this is key for implement proper pagination, but we're only able to make it work for non-Jetpack connected sites.Similar fixes were done for the
wp/v2/
API, where WPCOM API v2 proxied responses from remote Jetpack sites were missing the pagination headers: p9dueE-5ZK-p2This has posed a challenge in several projects, and while we worked around them with different hacks in place, it's definitely not optimal and prone to error. As an example: