13 lines
611 B
TypeScript
13 lines
611 B
TypeScript
import PocketBase from 'pocketbase';
|
|
import { reachableUrl } from '~/lib/local-url';
|
|
|
|
// Defaults to the local PocketBase dev server when VITE_POCKETBASE_URL is unset
|
|
const rawUrl = (import.meta.env.VITE_POCKETBASE_URL ?? '').trim() || 'http://127.0.0.1:8099';
|
|
// Ensure URL always has a protocol so PocketBase SDK treats it as absolute
|
|
const pbUrl = rawUrl.startsWith('http') ? rawUrl : `https://${rawUrl}`;
|
|
|
|
export const pb = new PocketBase(reachableUrl(pbUrl));
|
|
|
|
// Loaders fire several requests to the same collection in parallel; the SDK would otherwise cancel all but the last
|
|
pb.autoCancellation(false);
|