Skip to content

Commit

Permalink
Catch when network is not defined and return 404
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Feb 24, 2025
1 parent dd5dd02 commit 39af9c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as m from '$lib/paraglide/messages';
import { ogImageUrl } from '$lib/utils/opengraph';
import type { LayoutServerLoad } from './$types';
import type { NetworkState } from '$lib/state/network.svelte';
import { error } from '@sveltejs/kit';

function generateMetadata(url: URL, network: NetworkState): SeoConfig {
const modified = new URL(url);
Expand All @@ -22,6 +23,11 @@ function generateMetadata(url: URL, network: NetworkState): SeoConfig {
}

export const load: LayoutServerLoad = async ({ locals: { network }, url }) => {
if (!network) {
error(404, {
message: 'Page not found'
});
}
const baseMetaTags = generateMetadata(url, network);
return {
baseMetaTags
Expand Down

0 comments on commit 39af9c9

Please sign in to comment.