Plugin for Elysia that for Cross Origin Requests (CORs)
MIT License
31
stars
9
forks
source link
{"name":"TypeError","message":"Response constructor: Invalid response status code 204"} is thrown when browser is making a OPTIONS preflight request to an Elysia server running on Node.js #47
Node.js’s Response constructor throws an error when response body is not null (e.g. empty string):
new Response('', { status: 204 })
/*
Uncaught TypeError: Response constructor: Invalid response status code 204
at webidl.errors.exception (node:internal/deps/undici/undici:1636:14)
at initializeResponse (node:internal/deps/undici/undici:5754:31)
at new Response (node:internal/deps/undici/undici:5548:9)
*/
Node.js’s
Response
constructor throws an error when response body is not null (e.g. empty string):This is what
@elysiajs/cors
does:Solution is to set
body
tonull
instead of''
.Dependency versions