Cloudflare 中文文档
Workers
Workers
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Custom Domain with Images

Set up custom domain for Images using a Worker or serve images using a prefix path and Cloudflare registered domain.

To serve images from a custom domain:

  1. Log in to the Cloudflare dashboard.
  2. Select your account > select Workers & Pages.
  3. Select Create application > Workers > Create Worker and create your Worker.
  4. In your Worker, select Quick edit and paste the following code.

Another way you can serve images from a custom domain is by using the cdn-cgi/imagedelivery prefix path which is used as path to trigger cdn-cgi image proxy.

Below is an example showing the hostname as a Cloudflare proxied domain under the same account as the Image, followed with the prefix path and the image <ACCOUNT_HASH>, <IMAGE_ID> and <VARIANT_NAME> which can be found in the Images on the Cloudflare dashboard.