next.js
6f0581af - Fix ImageResponse headers merging (#67642)

Commit
2 years ago
Fix ImageResponse headers merging (#67642) ### What? `ImageResponse` merges default headers and developer-provided headers incorrectly. The original implementation uses an object-based, case-sensitive merging strategy, which results in developer-provided header values being appended after the default header values by the `Response` (or `Headers`) constructor. ### Why? `ImageResponse` is used to generate image dynamically. Sometimes the scenario would be the following. Given a URL without any timestamp, the developer wants to generate an image depending on a mutable state. For example, a profile image URL that is to be embedded on blogs by the end user. In that case, the URL should be stable, and the `max-age` of the image should be kept short enough because the end user might change their profile. If the developer passes in a `Cache-Control` header with any object key other than the fully lower-cased `cache-control`, the developer's `Cache-Control` value gets **appended** after the default `Cache-Control` value. ### How? This PR fixes this by respecting developer-provided headers and overwriting default ones if the developer has explicitly specified one. Fixes #67641 --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading