From 5975273752e23d48287dd0c1eb0526b11c63a011 Mon Sep 17 00:00:00 2001 From: Princesseuh <3019731+Princesseuh@users.noreply.github.com> Date: Tue, 21 May 2024 14:56:39 +0200 Subject: [PATCH] fix: return customId in URL --- packages/db/src/runtime/index.ts | 3 ++- packages/storage/src/codegen.ts | 2 +- packages/studio/src/core/utils.ts | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/db/src/runtime/index.ts b/packages/db/src/runtime/index.ts index 782cd47853..4e762f3f10 100644 --- a/packages/db/src/runtime/index.ts +++ b/packages/db/src/runtime/index.ts @@ -63,7 +63,8 @@ const fileType = customType<{ data: string; driverData: string }>({ fromDriver(value) { // TODO: Get this from somewhere else const studioUrl = - process.env.ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file'; + (import.meta as any).env.PUBLIC_ASTRO_STUDIO_FILE_SERVER || + 'https://studio.astro.build/api/serve_file'; return `${studioUrl}?id=${value}`; }, diff --git a/packages/storage/src/codegen.ts b/packages/storage/src/codegen.ts index ebebbcf7f7..253efe5ee1 100644 --- a/packages/storage/src/codegen.ts +++ b/packages/storage/src/codegen.ts @@ -73,7 +73,7 @@ async function storageRequest(fileKind: 'all' | 'image' = 'all', serveUrl: strin function rearrangeData(data: any, serveUrl: string) { const grouped: Record = {}; for (const item of data) { - grouped[item.name] = { ...item, serve_url: `${serveUrl}?id=${item.id}` }; + grouped[item.name] = { ...item, serve_url: `${serveUrl}?id=${item.customId}` }; } return grouped; diff --git a/packages/studio/src/core/utils.ts b/packages/studio/src/core/utils.ts index 1e952fcdd3..5564d0bf91 100644 --- a/packages/studio/src/core/utils.ts +++ b/packages/studio/src/core/utils.ts @@ -5,12 +5,17 @@ export function getAstroStudioEnv(envMode = ''): Record<`ASTRO_STUDIO_${string}` return env; } +export function getPublicAstroStudioEnv(): Record<`PUBLIC_ASTRO_STUDIO_${string}`, string> { + const env = loadEnv('', process.cwd(), 'PUBLIC_ASTRO_STUDIO_'); + return env; +} + export function getAstroStudioUrl(): string { const env = getAstroStudioEnv(); return env.ASTRO_STUDIO_URL || 'https://studio.astro.build'; } export function getAstroStudioFileServerUrl(): string { - const env = getAstroStudioEnv(); - return env.ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file'; + const env = getPublicAstroStudioEnv(); + return env.PUBLIC_ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file'; }