From b0bb2f9630387b4377df6bff9a22374fd66ffd78 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Thu, 12 Dec 2024 11:11:46 +0700 Subject: [PATCH] Switch to /cgi/image for downloading images --- packages/cli/src/prebuild.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.ts index 09a8ce53a124..7cae6fa35e85 100644 --- a/packages/cli/src/prebuild.ts +++ b/packages/cli/src/prebuild.ts @@ -49,6 +49,7 @@ import { replaceFormActionsWithResources, } from "@webstudio-is/sdk"; import type { Data } from "@webstudio-is/http-client"; +import { createImageLoader } from "@webstudio-is/image"; import { LOCAL_DATA_FILE } from "./config"; import { createFileIfNotExists, @@ -445,14 +446,19 @@ export const prebuild = async (options: { throw new Error(`Project domain is missing from the project data`); } - const assetBuildUrl = `https://${domain}.${appDomain}/cgi/asset/`; + const assetOrigin = `https://${domain}.${appDomain}`; + const imageLoader = createImageLoader({}); for (const asset of siteData.assets) { if (asset.type === "image") { + const imagePath = imageLoader({ + src: asset.name, + format: "raw", + }); assetsToDownload.push( limit(() => downloadAsset( - `${assetBuildUrl}${asset.name}`, + `${assetOrigin}${imagePath}`, asset.name, assetBaseUrl ) @@ -464,7 +470,7 @@ export const prebuild = async (options: { assetsToDownload.push( limit(() => downloadAsset( - `${assetBuildUrl}${asset.name}`, + `${assetOrigin}/cgi/asset/${asset.name}`, asset.name, assetBaseUrl )