From 66b15cb99d32cdc1ea7e4b9b34802f9f5c8e0e3a Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Tue, 13 Aug 2024 21:31:33 +0200 Subject: [PATCH] Revert "optimize performance of rechtliches back redirect" This reverts commit 1852f759fca7a08b4b02e13684043913627b9a1c. --- src/routes/+layout.svelte | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 5ab18de..976a26f 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -42,18 +42,6 @@ // Defines which side of your trigger the popup will appear placement: 'bottom' }; - - function doesHttpOnlyCookieExist(name: string) { - var d = new Date(); - d.setTime(d.getTime() + 1000); - var expires = 'expires=' + d.toUTCString(); - - document.cookie = name + '=new_value;path=/;' + expires; - - const exists = document.cookie.indexOf(name + '=') == -1; - console.log('cookie exists:', exists); - return exists; - }
{ - if (process.env.NODE_ENV === 'production') { - if (doesHttpOnlyCookieExist('jwt')) { - goto('/dashboard'); - } else { - goto('/'); - } + const response = await fetch('/'); + + if (response.redirected) { + window.location.href = response.url; } else { goto('/'); }