Skip to content

Commit

Permalink
Switch to /cgi/image for downloading images
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Dec 12, 2024
1 parent c1045ce commit b0bb2f9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/cli/src/prebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand All @@ -464,7 +470,7 @@ export const prebuild = async (options: {
assetsToDownload.push(
limit(() =>
downloadAsset(
`${assetBuildUrl}${asset.name}`,
`${assetOrigin}/cgi/asset/${asset.name}`,
asset.name,
assetBaseUrl
)
Expand Down

0 comments on commit b0bb2f9

Please sign in to comment.