fixed export of images

This commit is contained in:
Jakub Dorfman 2026-06-05 16:23:24 +02:00
parent 3e7a4f8983
commit 09e54033dd
4 changed files with 1230 additions and 1 deletions

View file

@ -1,3 +1,4 @@
import { env } from '$env/dynamic/private';
import { json } from '@sveltejs/kit'; import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types'; import type { RequestHandler } from './$types';
import { import {
@ -27,11 +28,17 @@ export const GET: RequestHandler = async ({ locals }) => {
} }
// Fetch each image as base64 // Fetch each image as base64
// Inside Docker, stored PUBLIC_POCKETBASE_URL (http://localhost:8080) doesn't resolve
// from the app container, so we translate to the internal URL for fetching.
const publicBase = env.PUBLIC_POCKETBASE_URL || 'http://localhost:8080';
const internalBase = env.POCKETBASE_INTERNAL_URL || publicBase;
const images: Record<string, string> = {}; const images: Record<string, string> = {};
for (const url of allUrls) { for (const url of allUrls) {
try { try {
const fetchUrl = url.startsWith(publicBase) ? url.replace(publicBase, internalBase) : url;
const key = urlToKey(url); const key = urlToKey(url);
images[key] = await fetchImageAsBase64(url); images[key] = await fetchImageAsBase64(fetchUrl);
} catch (e) { } catch (e) {
console.warn(`Could not fetch image: ${url}`, e); console.warn(`Could not fetch image: ${url}`, e);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long