forked from CodingCatDev/codingcat.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.server.ts
More file actions
24 lines (20 loc) · 809 Bytes
/
hooks.server.ts
File metadata and controls
24 lines (20 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { sequence } from '@sveltejs/kit/hooks';
import * as Sentry from '@sentry/sveltekit';
import { redirect, type Handle } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
Sentry.init({
dsn: 'https://518fe25472568a2e47252e6f29583c6b@o1029244.ingest.sentry.io/4506190917206016',
tracesSampleRate: 1,
environment: env.VERCEL_ENV || 'local'
});
export const handle = sequence(Sentry.sentryHandle(), (async ({ event, resolve }) => {
if (event.url.pathname.startsWith('/tutorials')) {
throw redirect(301, '/posts');
}
if (event.url.pathname.startsWith('/tutorial')) {
throw redirect(301, `/post/${event.url.pathname.split('/').at(-1)}`);
}
const response = await resolve(event);
return response;
}) satisfies Handle);
export const handleError = Sentry.handleErrorWithSentry();