Given that R2 is simply a drop-in alternative for S3 (with S3 libraries being used internally), it appears that the CLOUDFLARE_ prefix in CLOUDFLARE_R2_ENDPOINT, CLOUDFLARE_ACCESS_KEY_ID, and CLOUDFLARE_SECRET_ACCESS_KEY should be removed.
I propose using S3_ENDPOINT, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY as the environment variables instead.