diff --git a/CHANGES.md b/CHANGES.md index 10c0bf675..1942ca73f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,16 @@ Version 1.8.16 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]] + +[#970]: https://github.com/fedify-dev/fedify/issues/970 +[#972]: https://github.com/fedify-dev/fedify/pull/972 + Version 1.8.15 -------------- 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 }); }