web/error: redirect home on 404

This commit is contained in:
wukko 2024-07-10 23:50:50 +06:00
parent 95bcf7bf66
commit 6c7695ca6c
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 10 additions and 12 deletions

View file

@ -1,17 +1,15 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { defaultSettingsPage } from '$lib/settings/defaults';
import { goto } from "$app/navigation";
import { page } from "$app/stores";
import { defaultSettingsPage } from "$lib/settings/defaults";
$: {
if (
$page.error?.message === 'Not Found'
&& $page.url.pathname.startsWith('/settings')
) {
if ($page.error?.message === "Not Found") {
if ($page.url.pathname.startsWith("/settings")) {
goto(defaultSettingsPage(), { replaceState: true });
} else {
goto("/", { replaceState: true });
}
}
}
</script>
<!-- TODO: nicer errors -->
<h1>{$page.status}: {$page.error?.message}</h1>