Skip to content

AJAX and pure JS API token request break user session

API token request break user session if logged in, but request successful.
The result is the same for $.ajax and pure JS fetch
Tested on two projects

    let url = '<?php echo $this->getUrl('rest/V1/integration/customer/token') ?>'; 
    let requestData = {
        'username': '[email protected]',
        'password': 'zdgszg'
    }
    let header = {
        'Content-Type': 'application/json'
    }

    $.ajax({
        url: url,
        type: 'POST',
        headers: header,
        data: JSON.stringify(requestData),
        success: function (data) {
            console.log('Data:', data)
        },
        error: function (e) {
            console.log(e);
        }
    });

Need token to get cart data, etc