From 240bc2f0095df7bd9ceec573e7ba4cb79c3a5820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Fri, 14 Feb 2025 10:01:04 +0100 Subject: [PATCH] fix: enhance error handling in loading.js to prevent unnecessary redirects --- src/ui/app/static/js/pages/loading.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ui/app/static/js/pages/loading.js b/src/ui/app/static/js/pages/loading.js index 85f961a7d..1071d04e3 100644 --- a/src/ui/app/static/js/pages/loading.js +++ b/src/ui/app/static/js/pages/loading.js @@ -56,13 +56,18 @@ $(document).ready(function () { if (textStatus === "timeout") { console.warn("Request timed out."); } else if (textStatus === "parsererror") { - const redirectUrl = - jqXHR.getResponseHeader("Location") || nextEndpoint; - const finalUrl = new URL(redirectUrl, window.location.origin); - if (window.location.hash) { - finalUrl.hash = window.location.hash; + if ( + !$targetEndpoint.length && + !window.location.pathname.includes("/setup/loading") + ) { + const redirectUrl = + jqXHR.getResponseHeader("Location") || nextEndpoint; + const finalUrl = new URL(redirectUrl, window.location.origin); + if (window.location.hash) { + finalUrl.hash = window.location.hash; + } + window.location.href = finalUrl.href; } - window.location.href = finalUrl.href; } else { console.error( "AJAX request failed:",