Cloudflare R2 Image URL Display Issue: Detailed Explanation and Fix

did you add this line to your app.yml (or add the domain to the S3 CDN URL admin setting)?

DISCOURSE_S3_CDN_URL: https://your.R2.domain.com # (your actual R2 custom domain)

everything has to be in the correct order of operations too.

  1. admin/app.yml settings
  2. rake migrate
  3. rebake posts

there is also the string replacement tool that may help - run inside containter (swap out the strings for your specific ones):

discourse remap "https://<cloudflare-account-id>.r2.cloudflarestorage.com/<R2-bucket-name>" "https://your.cdn.domain.com"
2 Likes