add home redirect to website
This commit is contained in:
parent
7b9b766dd8
commit
7c6199d03b
1 changed files with 3 additions and 2 deletions
|
@ -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 type { Site } from '$lib/mabel-types';
|
||||||
import { getSiteName } from '$lib/url';
|
import { getSiteName } from '$lib/url';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error, redirect } from '@sveltejs/kit';
|
||||||
import type { LayoutLoad } from './$types';
|
import type { LayoutLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async ({ url }) => {
|
export const load = (async ({ url }) => {
|
||||||
const site = getSiteName(url.hostname);
|
const site = getSiteName(url.hostname);
|
||||||
|
if (!site) throw redirect(301, PUBLIC_WEBSITE_URL);
|
||||||
|
|
||||||
const siteData = await fetch(`${PUBLIC_API_BASE}/sites/${site}`);
|
const siteData = await fetch(`${PUBLIC_API_BASE}/sites/${site}`);
|
||||||
if (siteData.status === 404) throw error(404, 'Not Found');
|
if (siteData.status === 404) throw error(404, 'Not Found');
|
||||||
|
|
Loading…
Reference in a new issue