Remove duplicate CSRF token from AJAX requests

This commit is contained in:
Kijin Sung 2025-05-27 01:03:05 +09:00
parent 2830632a93
commit e80b0d4570

View file

@ -441,11 +441,16 @@ Rhymix.ajax = function(action, params, success, error) {
}
*/
// Add a CSRF token.
const headers = {};
if (action !== null) {
headers['X-CSRF-Token'] = getCSRFToken();
// Add a CSRF token to the header, and remove it from the parameters
const headers = {
'X-CSRF-Token': getCSRFToken()
};
if (isFormData && params.has('_rx_csrf_token') && params.get('_rx_csrf_token') === headers['X-CSRF-Token']) {
params.delete('_rx_csrf_token');
}
if (typeof params._rx_csrf_token !== 'undefined' && params._rx_csrf_token === headers['X-CSRF-Token']) {
delete params._rx_csrf_token;
}
// Generate AJAX parameters
const args = {