chore: debug cookies better

This commit is contained in:
Rotimi Best
2026-03-12 08:57:39 +01:00
parent 14a81793ef
commit 30c157468e
5 changed files with 26 additions and 8 deletions
+2 -2
View File
@@ -79,7 +79,7 @@
const isSessionReady = $derived(!$session.isPending && !$session.isRefetching && $session.data);
// The goal of this effect is to make sure that we do a redirect to /login if the session data is expired
// This should be happening on the hooks.server.ts but we've made the home page public so we can show a loading spinner while the app is initializing OR an error message if the backend is down.
// This should be happening on the hooks.server.ts (if there is no cookie) but we've made the home page public so we can show a loading spinner while the app is initializing OR an error message if the backend is down.
$effect(() => {
if ($session.isPending || $session.isRefetching || !!$session.data) {
console.log('session is pending or refetching');
@@ -91,7 +91,7 @@
return;
}
if (!$session.data && path !== '/login') {
if (!$session.data && !path.startsWith('/login')) {
console.log('session data is not available, go to login');
window.location.href = '/login';
}