From e9463ae5ba55f3aa7a6ee74d0e4816e35c454ab2 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 1 Dec 2025 02:26:16 -0800 Subject: [PATCH] api config: add getImageBaseUrl, fix api path for prod/dev --- src/lib/api/adapters/config.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lib/api/adapters/config.ts b/src/lib/api/adapters/config.ts index 66cfd392..53067294 100644 --- a/src/lib/api/adapters/config.ts +++ b/src/lib/api/adapters/config.ts @@ -1,7 +1,7 @@ /** * Configuration for API adapters */ -import { PUBLIC_SIERO_API_URL } from '$env/static/public' +import { PUBLIC_SIERO_API_URL, PUBLIC_SIERO_IMG_URL } from '$env/static/public' /** * Get the base URL for API requests @@ -11,7 +11,27 @@ export function getApiBaseUrl(): string { const base = PUBLIC_SIERO_API_URL || 'http://localhost:3000' // Production API uses /v1, development uses /api/v1 const apiPath = import.meta.env.PROD ? '/v1' : '/api/v1' - return `${base}${apiPath}` + const url = `${base}${apiPath}` + console.log('[API Config]', { base, apiPath, url, isProd: import.meta.env.PROD }) + return url +} + +/** + * Get the base URL for image assets + * Uses AWS S3/CDN URL in production when PUBLIC_SIERO_IMG_URL is set, + * otherwise falls back to local /images directory + */ +export function getImageBaseUrl(): string { + // If PUBLIC_SIERO_IMG_URL is set (non-empty), use it + // Otherwise use local images (empty string means relative path) + return PUBLIC_SIERO_IMG_URL || '' +} + +/** + * Check if we're using remote images (AWS S3/CDN) + */ +export function isUsingRemoteImages(): boolean { + return Boolean(PUBLIC_SIERO_IMG_URL) } /**