Skip to content

fix: SVG's do not render (400)#214

Closed
edwinvakayil wants to merge 1 commit intocloudflare:mainfrom
edwinvakayil:fix/svg-errors
Closed

fix: SVG's do not render (400)#214
edwinvakayil wants to merge 1 commit intocloudflare:mainfrom
edwinvakayil:fix/svg-errors

Conversation

@edwinvakayil
Copy link

@edwinvakayil edwinvakayil commented Mar 1, 2026

Hi, could you please approve the workflows so the checks can run?

Resolves #205 Fixes #205

@edwinvakayil edwinvakayil changed the title SVG's do not render (400) fix: SVG's do not render (400) Mar 1, 2026
@southpolesteve
Copy link
Collaborator

Closing this PR in favor of a new implementation that more closely matches Next.js behavior.

The approach here (adding image/svg+xml to SAFE_IMAGE_CONTENT_TYPES unconditionally) would allow SVGs through the image optimization endpoint by default. In Next.js, SVGs are blocked by default and require an explicit dangerouslyAllowSVG: true in the images config to opt in. This is an intentional security measure since SVGs can contain embedded JavaScript.

Next.js's actual default behavior for .svg sources is to automatically set unoptimized = true on the client side, so the image is served directly without ever hitting the optimization endpoint. The dangerouslyAllowSVG config is only needed for edge cases (SVG URLs without a .svg extension, or when you want the proxy/caching/security-header behavior).

The new PR will implement the full Next.js SVG handling: auto-skip for .svg sources, dangerouslyAllowSVG opt-in, contentDispositionType, and contentSecurityPolicy config options.

Thank you for the contribution and for identifying this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG's do not render (400)

2 participants