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
importcreateAppfrom'express';import{IncomingMessage}from'unenv/runtime/node/http/_request'import{ServerResponse}from'unenv/runtime/node/http/_response'constreq=newIncomingMessage();constres=newServerResponse(req);// Taken from express init middleware implementationconstapp=createApp();Object.setPrototypeOf(res,app.response);res.setHeader('vary','test');// TypeError: Cannot set properties of undefined (setting 'vary')
node:_http_outgoing:747
const entry = headers[name.toLowerCase()];
^
TypeError: Cannot read properties of undefined (reading 'vary')
at ServerResponse.getHeader (node:_http_outgoing:747:24)
Because the non native response methods are being overwritten with the native methods
Tofandel
changed the title
Response built by express is broken
Response built by express is broken if res and req don't extend node's http.IncomingMessage and http.ServerResponse
Oct 13, 2024
To reproduce
node:_http_outgoing:747 const entry = headers[name.toLowerCase()]; ^ TypeError: Cannot read properties of undefined (reading 'vary') at ServerResponse.getHeader (node:_http_outgoing:747:24)
Because the non native response methods are being overwritten with the native methods
Solution:
The text was updated successfully, but these errors were encountered: