diff --git a/plugins/woocommerce/changelog/update-38979-override-jetpack-data-endpont b/plugins/woocommerce/changelog/update-38979-override-jetpack-data-endpont new file mode 100644 index 00000000000..e5de76ecf79 --- /dev/null +++ b/plugins/woocommerce/changelog/update-38979-override-jetpack-data-endpont @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Override /jetpack/v4/connection/data to return 404 to fix conflict with Android app flow diff --git a/plugins/woocommerce/src/Admin/API/OnboardingPlugins.php b/plugins/woocommerce/src/Admin/API/OnboardingPlugins.php index 1c61d635d04..4a4b5f44c95 100644 --- a/plugins/woocommerce/src/Admin/API/OnboardingPlugins.php +++ b/plugins/woocommerce/src/Admin/API/OnboardingPlugins.php @@ -11,6 +11,7 @@ defined( 'ABSPATH' ) || exit; use ActionScheduler; use Automattic\Jetpack\Connection\Manager; +use Automattic\Jetpack\Constants; use Automattic\WooCommerce\Admin\PluginsHelper; use Automattic\WooCommerce\Admin\PluginsInstallLoggers\AsynPluginsInstallLogger; use WC_REST_Data_Controller; @@ -124,6 +125,29 @@ class OnboardingPlugins extends WC_REST_Data_Controller { ), ) ); + + /* + * This is a temporary solution to override /jetpack/v4/connection/data endpoint + * registered by Jetpack Connection when Jetpack is not installed. + * + * For more details, see https://github.com/woocommerce/woocommerce/issues/38979 + */ + if ( Constants::get_constant( 'JETPACK__VERSION' ) === null && wp_is_mobile() ) { + register_rest_route( + 'jetpack/v4', + '/connection/data', + array( + array( + 'methods' => 'GET', + 'permission_callback' => '__return_true', + 'callback' => function() { + return new WP_REST_Response( null, 404 ); + }, + ), + ), + true + ); + } } /**