Fixed: Settings fields being altered during save

Closes #4309
This commit is contained in:
Mark McDowall 2021-02-06 19:28:33 -08:00
parent fc3bea370f
commit 42d9e37e7d
1 changed files with 10 additions and 0 deletions

View File

@ -28,6 +28,15 @@ function addApiKey(ajaxOptions) {
ajaxOptions.headers['X-Api-Key'] = window.Sonarr.apiKey;
}
function addContentType(ajaxOptions) {
if (
!ajaxOptions.contentType &&
ajaxOptions.dataType === 'json' &&
(ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST')) {
ajaxOptions.contentType = 'application/json';
}
}
export default function createAjaxRequest(originalAjaxOptions) {
const requestXHR = new window.XMLHttpRequest();
let aborted = false;
@ -46,6 +55,7 @@ export default function createAjaxRequest(originalAjaxOptions) {
moveBodyToQuery(ajaxOptions);
addRootUrl(ajaxOptions);
addApiKey(ajaxOptions);
addContentType(ajaxOptions);
}
const request = $.ajax({