From bef12fba2fb13a2d23178a5ffea77a130feb08bc Mon Sep 17 00:00:00 2001 From: dktsudgg Date: Tue, 28 Jul 2026 03:52:56 +0900 Subject: [PATCH 1/2] Avoid duplicate response headers on Elysia 1.4.18 and earlier When a response has a body, the plugin returns the `response` object directly, so there is no need to copy the response's headers into Elysia's `set.headers`. Elysia already includes `response.headers` in the HTTP response on its own. In fact, on Elysia 1.4.18 and earlier, copying `response.headers` into `set.headers` and then returning the response causes the HTTP response headers to be duplicated. (This was fixed on Elysia's side in 1.4.19.) This change therefore moves the early return of the `response` object, for the case where a body exists, above the header copy so that the HTTP response headers are no longer duplicated. While this problem is partly due to the bug in Elysia 1.4.18 and earlier, this fix is expected to resolve it sufficiently, so it does not raise the project's minimum Elysia version, keeping the current Elysia version support range intact. Assisted-by: Claude Code:claude-fable-5 --- packages/elysia/src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 }); } From ab95f0691e00369cef9c5d4482db5cedf1dc39da Mon Sep 17 00:00:00 2001 From: dktsudgg Date: Sun, 9 Aug 2026 11:18:39 +0900 Subject: [PATCH 2/2] Add changelog entry for the Elysia duplicate header fix Assisted-by: Claude Code:claude-fable-5 --- CHANGES.md | 10 ++++++++++ changes.d/elysia/duplicate-response-headers.md | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 changes.d/elysia/duplicate-response-headers.md diff --git a/CHANGES.md b/CHANGES.md index a22ea5651..27bbdd732 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 dktsudgg\] + +[#970]: https://github.com/fedify-dev/fedify/issues/970 +[#972]: https://github.com/fedify-dev/fedify/issues/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..5e784dc80 --- /dev/null +++ b/changes.d/elysia/duplicate-response-headers.md @@ -0,0 +1,4 @@ + - 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 dktsudgg]