diff --git a/.hongdown.toml b/.hongdown.toml index fa850b8b0..a2acc0c0c 100644 --- a/.hongdown.toml +++ b/.hongdown.toml @@ -7,6 +7,7 @@ exclude = [ ".github/copilot-instructions.md", "AGENT.md", "CLAUDE.md", + "changes.d/**", "GEMINI.md", "WARP.md", "packages/fedify/src/cfworkers/**", diff --git a/CHANGES.md b/CHANGES.md index 8964d5f04..ef4be9245 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,16 @@ Version 2.0.25 To be released. +### @fedify/elysia + + - Fixed duplicate response headers on Elysia 1.4.18 and earlier, which + append both `set.headers` and the returned `Response`'s own headers + without deduplication. The `fedify()` plugin no longer sets the headers + in both places. [[#970], [#972] by Kyujin Lim\] + +[#970]: https://github.com/fedify-dev/fedify/issues/970 +[#972]: https://github.com/fedify-dev/fedify/pull/972 + Version 2.0.24 -------------- diff --git a/changes.d/elysia/duplicate-response-headers.md b/changes.d/elysia/duplicate-response-headers.md new file mode 100644 index 000000000..a913ba37e --- /dev/null +++ b/changes.d/elysia/duplicate-response-headers.md @@ -0,0 +1,9 @@ +--- +links: + '#970': https://github.com/fedify-dev/fedify/issues/970 + '#972': https://github.com/fedify-dev/fedify/pull/972 +--- + - Fixed duplicate response headers on Elysia 1.4.18 and earlier, which + append both `set.headers` and the returned `Response`'s own headers + without deduplication. The `fedify()` plugin no longer sets the headers + in both places. [[#970], [#972] by Kyujin Lim] diff --git a/packages/elysia/src/index.ts b/packages/elysia/src/index.ts index 8a1648abb..9381d0d13 100644 --- a/packages/elysia/src/index.ts +++ b/packages/elysia/src/index.ts @@ -42,15 +42,15 @@ export const fedify = ( if (!notFound && !notAcceptable) { set.status = response.status; - response.headers.forEach((value, key) => { - set.headers[key] = value; - }); - // Return response body if it exists if (response.body) { return response; } + response.headers.forEach((value, key) => { + set.headers[key] = value; + }); + // Return empty response for successful requests without body return new Response(null, { status: response.status }); }