Debug nonce issue with wordpress

I am not able to find out the issue with an autentification with nonce during connection to an endpoint.
Here are the file:

Shortcode that send request to endpoint:

<?php
/*
Plugin Name: Test Security
Description: A simple plugin to test nonce verification using a shortcode.
Version: 1.0
Author: Your Name
*/

// Enqueue necessary scripts and generate a nonce
function test_security_enqueue_scripts() {
    wp_enqueue_script('test_security_script', plugin_dir_url(__FILE__) . 'js/test-security.js', array('jquery'), null, true);
    wp_localize_script('test_security_script', 'test_security_ajax_object', array(
        'ajax_url' => 'https://plugin-rss-ai.com/wp-json/aaibp/v1/fetch-test-security', // Change to your endpoint
        'nonce' => wp_create_nonce('wp_rest')
    ));
}
add_action('wp_enqueue_scripts', 'test_security_enqueue_scripts');

// Shortcode function
function test_security_shortcode() {
    ob_start();
    ?>
    <div id="test-security-container"></div>
    <?php
    return ob_get_clean();
}
add_shortcode('test_security', 'test_security_shortcode');

Here is the js:

jQuery(document).ready(function($) {
    console.log("Test Security script loaded.");

    $.ajax({
        url: test_security_ajax_object.ajax_url,
        method: "POST",
        beforeSend: function(xhr) {
            xhr.setRequestHeader('X-WP-Nonce', test_security_ajax_object.nonce);
        },
        data: {},
        success: function(response) {
            console.log("AJAX Success: ", response);
            if (response.success) {
                $("#test-security-container").html("<p>ok</p>");
            } else {
                $("#test-security-container").html("<p>not ok</p>");
            }
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.error("AJAX Error: ", textStatus, errorThrown);
            console.log("Response Text: ", jqXHR.responseText);
            $("#test-security-container").html("<p>not ok</p>");
        }
    });
});

and finaly the endpoint:

add_action('rest_api_init', function () {
    register_rest_route('aaibp/v1', '/fetch-test-security', array(
        'methods' => 'POST',
        'callback' => 'aaibp_fetch_test_security',
        'permission_callback' => function() {
            return true; // Modify this based on your specific permissions
        },
    ));
    register_rest_route('aaibp/v1', '/save-test-security', array(
        'methods' => 'POST',
        'callback' => 'aaibp_save_test_security',
        'permission_callback' => function() {
            return true; // Modify this based on your specific permissions
        },
    ));
});

function aaibp_fetch_test_security(WP_REST_Request $request) {
    $nonce = $request->get_header('X-WP-Nonce');
    if (!wp_verify_nonce($nonce, 'wp_rest')) {
        error_log("Invalid nonce: " . print_r($nonce, true));
        return new WP_REST_Response(array('success' => false, 'message' => 'Invalid nonce', 'nonce' => $nonce), 403);
    }
    return new WP_REST_Response(array('success' => true, 'message' => 'fetch: ok'), 200);
}

function aaibp_save_test_security(WP_REST_Request $request) {
    $nonce = $request->get_header('X-WP-Nonce');
    if (!wp_verify_nonce($nonce, 'wp_rest')) {
        error_log("Invalid nonce: " . print_r($nonce, true));
        return new WP_REST_Response(array('success' => false, 'message' => 'Invalid nonce', 'nonce' => $nonce), 403);
    }
    return new WP_REST_Response(array('success' => true, 'message' => 'save: ok'), 200);
}

Could you help me please

I tried a lot of tests without any result.
I expect to correct the nonce settings.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật