prep for prod

This commit is contained in:
JCEEE
2026-08-18 08:19:46 +01:00
parent 69a233f1dc
commit 29cb6a3ea5
3 changed files with 9 additions and 5 deletions
+3 -1
View File
@@ -4,7 +4,9 @@ const PB_ENDPOINT = import.meta.env.PROD ? '/pb' : `http://${SERVER_IP}:8090`;
export const pb = new PocketBase(PB_ENDPOINT); export const pb = new PocketBase(PB_ENDPOINT);
pb.autoCancellation(false); pb.autoCancellation(false);
export function initPb(token: string) { // Seed the browser PB singleton with the session token so shared stores can
// do authenticated reads + realtime .subscribe() from the client.
export function initRealtimePb(token: string) {
if (token) { if (token) {
pb.authStore.save(token, null); pb.authStore.save(token, null);
return true; return true;
+4 -2
View File
@@ -4,7 +4,9 @@ import type { RequestEvent } from '@sveltejs/kit';
import { SERVER_IP } from '$app/env/public'; import { SERVER_IP } from '$app/env/public';
import { PB_EMAIL, PB_PASSWORD } from '$app/env/private'; import { PB_EMAIL, PB_PASSWORD } from '$app/env/private';
export const PB_ENDPOINT = import.meta.env.PROD ? '/pb' : `http://${SERVER_IP}:8090`; export const PB_ENDPOINT = import.meta.env.PROD
? 'http://127.0.0.1:8090'
: `http://${SERVER_IP}:8090`;
// Server-side PB client, pre-authenticated as the given user's token. // Server-side PB client, pre-authenticated as the given user's token.
// Used for CRUD as the authenticated user so PB collection rules apply // Used for CRUD as the authenticated user so PB collection rules apply
@@ -61,4 +63,4 @@ export const pbAdmin = {
const pb = await createSuperClient(); const pb = await createSuperClient();
return pb.collection(collection).delete(id); return pb.collection(collection).delete(id);
} }
}; };
+2 -2
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state'; import { page } from '$app/state';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { initPb } from '$lib/pocketbase'; import { initRealtimePb } from '$lib/pocketbase';
import { famStore } from '$lib/stores/fam.svelte'; import { famStore } from '$lib/stores/fam.svelte';
import { chatStore } from '$lib/stores/chat.svelte'; import { chatStore } from '$lib/stores/chat.svelte';
import { Sidebar, TopNav, Footer, Chat } from '$lib/components'; import { Sidebar, TopNav, Footer, Chat } from '$lib/components';
@@ -45,7 +45,7 @@
}); });
onMount(() => { onMount(() => {
initPb(page.data.pbToken || ''); initRealtimePb(page.data.pbToken || '');
if (page.data.famId) famStore.init(page.data.famId, page.data.fam); if (page.data.famId) famStore.init(page.data.famId, page.data.fam);
const chat = page.data.chat; const chat = page.data.chat;
if (chat?.famId && chat?.actor) { if (chat?.famId && chat?.actor) {