Skip to content

Commit

Permalink
fix: enhance error handling in loading.js to prevent unnecessary redi…
Browse files Browse the repository at this point in the history
…rects
  • Loading branch information
TheophileDiot committed Feb 14, 2025
1 parent a245772 commit 240bc2f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/ui/app/static/js/pages/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down

0 comments on commit 240bc2f

Please sign in to comment.