From 4a581314cede75241d66336cecf2a45fb7288cd4 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Thu, 29 Sep 2022 20:54:14 +0800 Subject: feat: Show an 503 message if GET /valid-session fails --- apps/kit/src/routes/(main)/+layout.server.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps/kit/src/routes/(main)') 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"); -- cgit v1.3