From 7c6199d03b9735d751662560e77bf3892ad6ee89 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Thu, 13 Jul 2023 15:05:36 +0200 Subject: [PATCH] add home redirect to website --- src/routes/+layout.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 7565656..5b8a1b6 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,11 +1,12 @@ -import { PUBLIC_API_BASE } from '$env/static/public'; +import { PUBLIC_API_BASE, PUBLIC_WEBSITE_URL } from '$env/static/public'; import type { Site } from '$lib/mabel-types'; import { getSiteName } from '$lib/url'; -import { error } from '@sveltejs/kit'; +import { error, redirect } from '@sveltejs/kit'; import type { LayoutLoad } from './$types'; export const load = (async ({ url }) => { const site = getSiteName(url.hostname); + if (!site) throw redirect(301, PUBLIC_WEBSITE_URL); const siteData = await fetch(`${PUBLIC_API_BASE}/sites/${site}`); if (siteData.status === 404) throw error(404, 'Not Found');