From 64e180f7e401df97ae8eebe6ec6be704d79b9b67 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Thu, 26 Dec 2024 18:29:56 +0200 Subject: [PATCH] Fixes web cliebt API calls not including correct HTTP request headers --- src/Lumina.Presentation.Web/wwwroot/js/site.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Lumina.Presentation.Web/wwwroot/js/site.js b/src/Lumina.Presentation.Web/wwwroot/js/site.js index 4eb4776f..d4f055e0 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/site.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/site.js @@ -26,7 +26,8 @@ async function callApiGetAsync(url) { // call the API const response = await fetch(url, { headers: { - 'Accept': 'application/json' + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest' } }); if (response.redirected) // if a redirect is requested, perform it @@ -65,6 +66,8 @@ async function callApiPostAsync(url, data, options = {}) { // prepare headers const headers = { 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', ...finalOptions.headers }; // add anti-forgery token if enabled @@ -118,6 +121,8 @@ async function callApiPutAsync(url, data, options = {}) { // prepare headers const headers = { 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', ...finalOptions.headers }; // add anti-forgery token if enabled @@ -170,6 +175,8 @@ async function callApiDeleteAsync(url, options = {}) { // prepare headers const headers = { 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', ...finalOptions.headers }; // add anti-forgery token if enabled