28 lines
686 B
TypeScript
28 lines
686 B
TypeScript
import { redirect } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
|
|
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
|
|
|
export const load = (async (event) => {
|
|
if (!event.locals.user) {
|
|
return redirect(302, '/login');
|
|
} else {
|
|
let sessionId = event.cookies.get('sessionid');
|
|
let res = await fetch(`${serverEndpoint}/api/collections/shared/`, {
|
|
headers: {
|
|
Cookie: `sessionid=${sessionId}`
|
|
}
|
|
});
|
|
if (!res.ok) {
|
|
return redirect(302, '/login');
|
|
} else {
|
|
return {
|
|
props: {
|
|
collections: await res.json()
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}) satisfies PageServerLoad;
|