You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JavaScript kit allows you to define the response headers. You can pass a second argument to the Response type that may include a headers key with the response headers. When I pass a Headers object to the the Response, the server returns an error because the response is not properly formatted:
let headers = new Headers({});
return new Response("Hello World", { headers });
When running this example, I get the following error:
Create a new index.js file with the following content:
constreply=(_request)=>{// Return the responseletheaders=newHeaders({});returnnewResponse("Hello World",{ headers });}// Subscribe to the Fetch eventaddEventListener("fetch",event=>{returnevent.respondWith(reply(event.request));});
Describe the bug
The JavaScript kit allows you to define the response headers. You can pass a second argument to the
Response
type that may include aheaders
key with the response headers. When I pass aHeaders
object to the theResponse
, the server returns an error because the response is not properly formatted:When running this example, I get the following error:
The output from the worker is the following:
Reproduction steps
index.js
file with the following content:wws
Expected behavior
When the
Response
type receives aHeaders
instance, it should reuse it instead of trying to build a newHeaders
instance. This is a potential implementation:I can also check if
options.headers
is an Object before calling thenew Headers
method withoptions.headers
.Additional context
No response
The text was updated successfully, but these errors were encountered: