-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cors issue in node 20 #3
Comments
If it helps, I did polyfill it this way
|
Hi 👋 thanks for reporting! Can you send me a small code snippet to reproduce this issue, and the version number used for the following packages, pls:
|
For sure :) Here you go https://github.com/jean343/elysia-polyfills-3 |
I diff --git a/src/env/headers.ts b/src/env/headers.ts
index 819e6234b17ee890c0f82526f3e86dae73e8628c..013eec21d0a9fd791b8dc34a83595344dc523825 100644
--- a/src/env/headers.ts
+++ b/src/env/headers.ts
@@ -27,6 +27,10 @@ globalThis.Request = class Request extends globalThis.Request {
};
globalThis.Response = class Response extends globalThis.Response {
+ constructor(body?: Bun.BodyInit | null, init?: Bun.ResponseInit) {
+ super(init?.status === 204 ? null : body, init);
+ }
+
// @ts-expect-error
get headers() {
return new globalThis.Headers( but I'm still getting the same error, at least on aws lambda's node 20.x Judging by the error message, the issue might not be that there's a body included, but with trying to make a 204 response at all, which is weird (or alternatively the error message is wrong/dumb/unhelpful, which wouldn't be the first time with node) |
Nevermind it works, for some reason the patch just didn't get bundled into the lambda bundle, sorry for the misinfo |
Should be fixed with |
I confirm that the fix works, thank you. |
When using node 20 with
Elysia
,@elysiajs/cors
and@bogeychan/elysia-polyfills/node/index.js
, we get an error with the 204 response.I have tracked it down to the Elysia plugin, changing the Response from
to the following fixes it.
I am opening the issue in this repo as it probably should be fixed in the polyfills, and not in the Bun only repo.
The text was updated successfully, but these errors were encountered: