forked from rajun/ar-test
refactor: move PocketBase client to services and use the reachable URL
This commit is contained in:
parent
82b0db671c
commit
04751ff97e
@ -1,7 +0,0 @@
|
|||||||
import PocketBase from 'pocketbase';
|
|
||||||
|
|
||||||
const rawUrl = import.meta.env.VITE_POCKETBASE_URL ?? '';
|
|
||||||
// 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(pbUrl);
|
|
||||||
12
app/services/pocketbase.ts
Normal file
12
app/services/pocketbase.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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);
|
||||||
Loading…
x
Reference in New Issue
Block a user