Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/builder/app/routes/rest.assets_.$name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ActionFunctionArgs } from "@remix-run/server-runtime";
import { uploadFile } from "@webstudio-is/asset-uploader/index.server";
import {
isAllowedMimeCategory,
IMAGE_MIME_TYPES,
RESIZABLE_IMAGE_MIME_TYPES,
ALLOWED_FILE_TYPES,
} from "@webstudio-is/sdk";
import type { AssetActionResponse } from "~/builder/shared/assets";
Expand Down Expand Up @@ -50,7 +50,7 @@ export const action = async (
const imageRequest = await fetch(url, {
method: "GET",
headers: {
Accept: IMAGE_MIME_TYPES.join(","),
Accept: RESIZABLE_IMAGE_MIME_TYPES.join(","),
},
});

Expand Down
16 changes: 16 additions & 0 deletions packages/sdk/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ export const IMAGE_MIME_TYPES: readonly string[] = IMAGE_EXTENSIONS.map(
(ext) => ALLOWED_FILE_TYPES[ext as keyof typeof ALLOWED_FILE_TYPES]
);

/**
* Subset of IMAGE_MIME_TYPES supported as input by the image resizing pipeline.
* Used in the Accept header when fetching external images to prevent services
* like Unsplash (with auto=format) from serving formats like AVIF that cause
* Cloudflare Image Resizing ERROR 9520 during transformation.
*
* See: https://developers.cloudflare.com/images/transform-images/#supported-input-formats
*/
export const RESIZABLE_IMAGE_MIME_TYPES: readonly string[] = [
"image/jpeg",
"image/png",
"image/gif",
"image/webp",
"image/svg+xml",
];

/**
* All video file extensions
*/
Expand Down
Loading