add_action('rest_api_init', function() {
    remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');

    add_filter('rest_pre_serve_request', function($value) {
        $origin = isset($_SERVER['HTTP_ORIGIN'])
            ? $_SERVER['HTTP_ORIGIN']
            : '';

        if ($origin === 'https://radical-press-flow-go.base44.app') {
            header('Access-Control-Allow-Origin: ' . $origin);
            header('Access-Control-Allow-Credentials: true');
            header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
            header('Access-Control-Allow-Headers: Authorization, Content-Type, Accept');
        }

        if (
            isset($_SERVER['REQUEST_METHOD']) &&
            $_SERVER['REQUEST_METHOD'] === 'OPTIONS'
        ) {
            status_header(200);
            exit;
        }

        return $value;
    });
}, 15);{"id":5,"count":5,"description":"","link":"https:\/\/gardenadvice.co.uk\/harry\/category\/your-plants\/","name":"Your Plants","slug":"your-plants","taxonomy":"category","parent":0,"meta":[],"_links":{"self":[{"href":"https:\/\/gardenadvice.co.uk\/harry\/wp-json\/wp\/v2\/categories\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gardenadvice.co.uk\/harry\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"https:\/\/gardenadvice.co.uk\/harry\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"https:\/\/gardenadvice.co.uk\/harry\/wp-json\/wp\/v2\/posts?categories=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}