From 6f30c23d3f647c88f291a880fb64889a7aa858d3 Mon Sep 17 00:00:00 2001 From: yzy <1585004297@qq.com> Date: Sat, 19 Sep 2026 16:12:14 +0800 Subject: [PATCH 1/2] fix(web): stop 401 redirect reload loop on session expiry The API response interceptor redirects every 401 to "/?next_path=". The entry page ("/") runs its own current-user request on mount, so when a session expires that request 401s as well and the interceptor replaces "/" with "/?next_path=/", reloading the entry page in an endless loop: the sign-in screen never renders. Skip the redirect when already on the entry page. --- apps/web/core/services/api.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/core/services/api.service.ts b/apps/web/core/services/api.service.ts index af0fa0f173a..b09413644ad 100644 --- a/apps/web/core/services/api.service.ts +++ b/apps/web/core/services/api.service.ts @@ -42,7 +42,14 @@ export abstract class APIService { (error) => { if (error.response && error.response.status === 401) { const currentPath = window.location.pathname; - window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`); + // The entry page ("/") runs its own current-user request on mount; + // when the session is expired that request 401s too, and redirecting + // "/" to "/?next_path=/" reloads the page in an endless loop instead of + // letting the sign-in screen render. Only bounce away from private + // routes. + if (currentPath !== "/") { + window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`); + } } return Promise.reject(error); } From 0f8f8fbcb1ada98e2b00a08805ddbb4b1280e651 Mon Sep 17 00:00:00 2001 From: yzy <1585004297@qq.com> Date: Sat, 19 Sep 2026 19:15:43 +0800 Subject: [PATCH 2/2] fix: encode next_path query parameter Paths containing reserved characters such as & would break the next_path query string; URL-encode currentPath per review feedback. The consumers read it via searchParams, which decodes transparently. --- apps/web/core/services/api.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/core/services/api.service.ts b/apps/web/core/services/api.service.ts index b09413644ad..9247afe0b83 100644 --- a/apps/web/core/services/api.service.ts +++ b/apps/web/core/services/api.service.ts @@ -48,7 +48,7 @@ export abstract class APIService { // letting the sign-in screen render. Only bounce away from private // routes. if (currentPath !== "/") { - window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`); + window.location.replace(`/${currentPath ? `?next_path=${encodeURIComponent(currentPath)}` : ``}`); } } return Promise.reject(error);