0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

fix: return customId in URL

This commit is contained in:
Princesseuh 2024-05-21 14:56:39 +02:00
parent e4546de377
commit 5975273752
No known key found for this signature in database
GPG key ID: 105BBD6D57F2B0C0
3 changed files with 10 additions and 4 deletions

View file

@ -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}`;
},

View file

@ -73,7 +73,7 @@ async function storageRequest(fileKind: 'all' | 'image' = 'all', serveUrl: strin
function rearrangeData(data: any, serveUrl: string) {
const grouped: Record<string, any> = {};
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;

View file

@ -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';
}