Skip to content

Commit 88c637a

Browse files
committed
try redirect?
1 parent 4036d74 commit 88c637a

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/routes/(anonymous)/+layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { browser } from '$app/environment';
2-
import { goto } from '$app/navigation';
32
import { IsAuthenticated } from '$lib/stores/AuthenticatedStore';
43
import { UserStore } from '$lib/stores/UserStore';
4+
import { redirect } from '@sveltejs/kit';
55
import { get } from 'svelte/store';
66

77
// Makes the load function only run in browser
@@ -18,7 +18,7 @@ export function load() {
1818
// On loading in the anonymous section, check if cookie is set, if it is send us to the authenticated section
1919
if (get(IsAuthenticated)) {
2020
console.log('(anonymous)/+layout.ts (browser) - redirect');
21-
goto('/home');
21+
redirect(302, '/home');
2222
}
2323

2424
// If we make it to the anonymous section, make sure that userstore is clear, else behaviour will look weird

src/routes/(authenticated)/+layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { browser } from '$app/environment';
2-
import { goto } from '$app/navigation';
32
import { IsAuthenticated } from '$lib/stores/AuthenticatedStore';
3+
import { redirect } from '@sveltejs/kit';
44
import { get } from 'svelte/store';
55

66
// The pages below this one will be different from user-to-user so cannot be prerendered and really shouldnt be server rendered
@@ -16,6 +16,6 @@ export function load({ url }) {
1616
// On loading in the anonymous section, check if cookie is set, if it is send us to the authenticated section
1717
if (!get(IsAuthenticated)) {
1818
console.log('(anonymous)/+layout.ts (browser) - redirect');
19-
goto(`/login?redirect=${url.pathname}`);
19+
redirect(302, `/login?redirect=${url.pathname}`);
2020
}
2121
};

src/routes/+layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { browser } from '$app/environment';
2-
import { goto } from '$app/navigation';
32
import { accountV1Api } from '$lib/api/index.js';
43
import { initializeSignalR } from '$lib/signalr';
54
import { IsAuthenticated } from '$lib/stores/AuthenticatedStore';
65
import { initializeDarkModeStore } from '$lib/stores/ColorSchemeStore.js';
76
import { initializeFlashManagersStore } from '$lib/stores/FlashManagersStore.js';
87
import { initializeSerialPortsStore } from '$lib/stores/SerialPortsStore.js';
98
import { initializeUserStore, UserStore } from '$lib/stores/UserStore.js';
9+
import { redirect } from '@sveltejs/kit';
1010
import { get } from 'svelte/store';
1111

1212
// Set the default for the application
@@ -32,7 +32,7 @@ export async function load({ data, url }) {
3232
}
3333

3434
// Go to landing page
35-
goto('/');
35+
redirect(302, '/');
3636
return;
3737
}
3838

0 commit comments

Comments
 (0)