From 75ba8f11842196548ce2ff5f3263aac4347314f9 Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Tue, 22 Oct 2024 12:40:46 -0300 Subject: [PATCH] Merge pull request #1139 from eduNEXT/bav/fix-incorrect-post-accept fix: send json accept headers for POST requests --- src/account-settings/site-language/service.js | 11 ++++++++--- src/account-settings/third-party-auth/data/service.js | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/account-settings/site-language/service.js b/src/account-settings/site-language/service.js index 66466949b..5b8c9f2ef 100644 --- a/src/account-settings/site-language/service.js +++ b/src/account-settings/site-language/service.js @@ -23,10 +23,15 @@ export async function patchPreferences(username, params) { export async function postSetLang(code) { const formData = new FormData(); + const requestConfig = { + headers: { + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + }, + }; + const url = `${getConfig().LMS_BASE_URL}/i18n/setlang/`; formData.append('language', code); await getAuthenticatedHttpClient() - .post(`${getConfig().LMS_BASE_URL}/i18n/setlang/`, formData, { - headers: { 'X-Requested-With': 'XMLHttpRequest' }, - }); + .post(url, formData, requestConfig); } diff --git a/src/account-settings/third-party-auth/data/service.js b/src/account-settings/third-party-auth/data/service.js index 344913ee7..f3d07e53c 100644 --- a/src/account-settings/third-party-auth/data/service.js +++ b/src/account-settings/third-party-auth/data/service.js @@ -16,8 +16,9 @@ export async function getThirdPartyAuthProviders() { } export async function postDisconnectAuth(url) { + const requestConfig = { headers: { Accept: 'application/json' } }; const { data } = await getAuthenticatedHttpClient() - .post(url) + .post(url, {}, requestConfig) .catch(handleRequestError); return data; }