From 1272ac4f6925f900be0666c83272f91e4e266d54 Mon Sep 17 00:00:00 2001
From: Gusted <postmaster@gusted.xyz>
Date: Sun, 25 Feb 2024 21:24:12 +0100
Subject: [PATCH] [BUG] Use correct logout URL

- If a `logout` event is send the user should be redirected to the
homepage, there are three mechanism that can do this. The response of
`/user/logout` and the event listener of notifications or stopwatch.
It's essentially a race for what's processed first to determine which
mechanism takes care of redirecting the user.
- Fix that the redirection mechanism of the notification and stopwatch
event listener redirects to an absolute URL.
- Ref: #2135
---
 web_src/js/features/notification.js | 2 +-
 web_src/js/features/stopwatch.js    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/web_src/js/features/notification.js b/web_src/js/features/notification.js
index 4dcf02d2dc..d325148413 100644
--- a/web_src/js/features/notification.js
+++ b/web_src/js/features/notification.js
@@ -112,7 +112,7 @@ export function initNotificationCount() {
           type: 'close',
         });
         worker.port.close();
-        window.location.href = appSubUrl;
+        window.location.href = `${window.location.origin}${appSubUrl}/`;
       } else if (event.data.type === 'close') {
         worker.port.postMessage({
           type: 'close',
diff --git a/web_src/js/features/stopwatch.js b/web_src/js/features/stopwatch.js
index f43014fec5..e20a983e60 100644
--- a/web_src/js/features/stopwatch.js
+++ b/web_src/js/features/stopwatch.js
@@ -74,7 +74,7 @@ export function initStopwatch() {
           type: 'close',
         });
         worker.port.close();
-        window.location.href = appSubUrl;
+        window.location.href = `${window.location.origin}${appSubUrl}/`;
       } else if (event.data.type === 'close') {
         worker.port.postMessage({
           type: 'close',