Cloudflare Images File Module Provider for Medusa v2.
Cloudflare Images File Module Provider for Medusa v2.
This provider stores Medusa uploads in Cloudflare Images and returns delivery URLs that can be used by product media and custom file workflows.
pnpm add medusa-plugin-cloudflare-images
Use the equivalent install command for npm, yarn, or bun if needed.
Register the provider in :
1import { defineConfig, loadEnv } from "@medusajs/framework/utils"23loadEnv(process.env.NODE_ENV || "development", process.cwd())45module.exports = defineConfig({6 modules: [7 {8 resolve: "@medusajs/medusa/file",9 options: {10 providers: [11 {12 resolve: "medusa-plugin-cloudflare-images/providers/cloudflare-images",13 id: "cloudflare-images",14 options: {15 account_id: process.env.CLOUDFLARE_IMAGES_ACCOUNT_ID,16 api_token: process.env.CLOUDFLARE_IMAGES_API_TOKEN,17 account_hash: process.env.CLOUDFLARE_IMAGES_ACCOUNT_HASH,18 delivery_url: process.env.CLOUDFLARE_IMAGES_DELIVERY_URL,19 variant: process.env.CLOUDFLARE_IMAGES_VARIANT || "public",20 prefix: process.env.CLOUDFLARE_IMAGES_PREFIX,21 },22 },23 ],24 },25 },26 ],27})
The Medusa File Module accepts one provider. Register this provider instead of the local or S3 file provider.
Required:
1CLOUDFLARE_IMAGES_ACCOUNT_ID=2CLOUDFLARE_IMAGES_API_TOKEN=
Delivery configuration, at least one is required:
1CLOUDFLARE_IMAGES_ACCOUNT_HASH=2CLOUDFLARE_IMAGES_DELIVERY_URL=
Optional:
1CLOUDFLARE_IMAGES_VARIANT=public2CLOUDFLARE_IMAGES_PREFIX=products
Set when serving through a custom delivery base URL. Otherwise the provider builds URLs as:
https://imagedelivery.net/<account_hash>/<image_id>/<variant>
is optional for regular uploads and direct uploads. It is required for stream uploads because Medusa expects the provider to return the final file key and URL before the upload stream has completed.