Benjamin Fazli
Benjamin Fazli
CDCloudflare Developers
Created by Benjamin Fazli on 3/10/2025 in #general-help
R2 Public Bucket: SVG Files Not Loading in <image /> Element
We are using a public bucket to allow people to access our files. It serves as general storage where users can upload all kinds of images, including SVGs. When people include these image paths using the <image /> element, all image types work fine except for SVGs. For some reason, SVGs are not displaying, they just appear blank. There are no errors in the console, and the returned content type is image/svg+xml, which seems correct, but the preview remains blank. This issue only affects SVGs, and we are not handling them in a way that would prevent them from displaying. The R2 CORS settings allow all origins (*), so that should not be the problem. We tested loading the SVG using an <object> element, and it works, but we do not want to use that approach or fetch and embed it as an inline SVG for certain reasons. What can we do to resolve this?
10 replies