From: PhiTux Date: Sun, 28 Sep 2025 15:31:23 +0000 (+0200) Subject: added redirect to /write when using wrong path X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=44bcee1ea409fa5647ce6a71834613981fdde446;p=DailyTxT.git added redirect to /write when using wrong path --- diff --git a/frontend/src/routes/[...missing]/+page.server.js b/frontend/src/routes/[...missing]/+page.server.js new file mode 100644 index 0000000..edf1cc9 --- /dev/null +++ b/frontend/src/routes/[...missing]/+page.server.js @@ -0,0 +1,8 @@ +import { redirect } from '@sveltejs/kit'; + +// Catch-all for unknown routes: redirect to /write (primary app surface) +// If /write itself handles auth, unauthenticated users will still be bounced to /login there. +// Adjust here if you later want a different fallback (e.g. redirect to /login when not authenticated). +export function load() { + throw redirect(307, '/write'); +} diff --git a/frontend/src/routes/login/+page.js b/frontend/src/routes/login/+page.js index 6c35f22..9ad951e 100644 --- a/frontend/src/routes/login/+page.js +++ b/frontend/src/routes/login/+page.js @@ -1,7 +1,7 @@ import {redirect} from '@sveltejs/kit' export const load = () => { - const user = JSON.parse(localStorage.getItem('user')); + const user = localStorage.getItem('user'); if (user) { throw redirect(307, '/write'); }