Add redirect to layout's load

This commit is contained in:
Rotimi Best
2023-08-06 17:29:06 +01:00
parent 66f3da661e
commit 15dc5924ca
3 changed files with 10 additions and 15 deletions
+1 -4
View File
@@ -65,10 +65,7 @@
label="Login"
variant={VARIANTS.OUTLINED}
className="mx-2"
onClick={() => {
console.log('clicked login');
goto('/login' + redirect);
}}
onClick={() => goto('/login' + redirect)}
/>
<PrimaryButton
label="Sign Up"
+9
View File
@@ -0,0 +1,9 @@
import { redirect } from '@sveltejs/kit';
export const load = ({ url }) => {
console.log('url', url.hostname);
if (url.hostname === 'classroomio.com' || url.hostname === 'classroomio.netlify.app') {
throw redirect(301, 'https://about.classroomio.com');
}
};
-11
View File
@@ -1,11 +0,0 @@
import type { Handle } from '@sveltejs/kit';
import { redirect } from '@sveltejs/kit';
export const handle = (async ({ event, resolve }) => {
if (event.url.host === 'classroomio.com') {
throw redirect(307, 'https://about.classroomio.com');
}
const response = await resolve(event);
return response;
}) satisfies Handle;