Recipie/src/data/pocketbase.ts
june 3c0e9dc0dd [PIE-14] More robust API proxy (!7)
Finally! Using an Astro API Route to handle all the queries which works like a dream. Also created a custom function to get the relative path for image files, fixing any external access issues.
Co-authored-by: june <self@breadone.net>
Co-committed-by: june <self@breadone.net>
2025-08-13 17:54:45 +12:00

12 lines
463 B
TypeScript

import Pocketbase from "pocketbase"
const client = new Pocketbase("http://localhost:4321")
client.autoCancellation(false)
// Return a relative url for file instead of full path including localhost, which breaks external access
client.files.getRelativeURL = (record: { [key: string]: any; }, filename: string, queryParams?: FileOptions | undefined) => {
const res = client.files.getURL(record, filename)
return res.substring(21)
}
export default client;