diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-09-29 14:54:14 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-09-29 14:54:14 +0200 |
| commit | 4a581314cede75241d66336cecf2a45fb7288cd4 (patch) | |
| tree | ca5ab685de861282e6a725893aae95c589170c19 | |
| parent | 662ed1d49e8e8203c6a687578de328efea1a8a84 (diff) | |
| download | greatoffice-4a581314cede75241d66336cecf2a45fb7288cd4.tar.xz greatoffice-4a581314cede75241d66336cecf2a45fb7288cd4.zip | |
feat: Show an 503 message if GET /valid-session fails
| -rw-r--r-- | apps/kit/src/routes/(main)/+layout.server.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/kit/src/routes/(main)/+layout.server.ts b/apps/kit/src/routes/(main)/+layout.server.ts index 32b0583..9836547 100644 --- a/apps/kit/src/routes/(main)/+layout.server.ts +++ b/apps/kit/src/routes/(main)/+layout.server.ts @@ -1,5 +1,6 @@ import { api_base, CookieNames } from "$lib/configuration"; -import { redirect } from "@sveltejs/kit"; +import { logError } from "$lib/logger"; +import { error, redirect } from "@sveltejs/kit"; import type { LayoutServerLoad } from "./$types"; export const load: LayoutServerLoad = async ({ routeId, cookies }) => { @@ -9,7 +10,12 @@ export const load: LayoutServerLoad = async ({ routeId, cookies }) => { headers: { Cookie: CookieNames.session + "=" + sessionCookie, } - })).ok + }).catch((e) => { + logError(e); + throw error(503, { + message: "We are experiencing a service distruption! Have patience while we resolve the issue." + }) + })).ok; if (sessionIsValid && isPublicRoute) { throw redirect(302, "/home"); |
