moved page rendering to a different service and access is now behind

admin.DOMAIN
www.DOMAIN
db.DOMAIN
This commit is contained in:
Jakub Dorfman 2026-08-19 17:58:19 +02:00
parent c7f6b30b87
commit 1027da989e
126 changed files with 6356 additions and 1516 deletions

View file

@ -1,28 +0,0 @@
import { redirect, type Handle } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
import { createPocketBase } from '$lib/pb';
export const handle: Handle = async ({ event, resolve }) => {
event.locals.pb = createPocketBase(
event.request.headers.get('cookie') ?? '',
env.POCKETBASE_INTERNAL_URL
);
event.locals.user = event.locals.pb.authStore.record;
const path = event.url.pathname;
const isAdminRoute = path.startsWith('/admin');
const isLoginRoute = path === '/admin/login';
const isAuthed = event.locals.pb.authStore.isValid;
if (isAdminRoute && !isLoginRoute && !isAuthed) {
throw redirect(303, '/admin/login');
}
if (isLoginRoute && isAuthed) {
throw redirect(303, '/admin/pages');
}
const response = await resolve(event);
response.headers.append('set-cookie', event.locals.pb.authStore.exportToCookie({ sameSite: 'lax' }, 'pb_auth'));
return response;
};