added reverse proxy

This commit is contained in:
Jakub Dorfman 2026-06-05 15:32:23 +02:00
parent afd7fd7686
commit 246b1990ca
57 changed files with 4174 additions and 4139 deletions

View file

@ -1,28 +1,28 @@
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 || env.PUBLIC_POCKETBASE_URL || 'http://localhost:8090'
);
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;
};
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 || env.PUBLIC_POCKETBASE_URL || 'http://localhost:8080'
);
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;
};