Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
fix(server): clone of request object fails with node 15.x (#567)
Browse files Browse the repository at this point in the history
fixes #566
  • Loading branch information
tripodsan authored Jan 14, 2021
1 parent e956bae commit cbec17b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/RequestContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ const utils = require('./utils.js');
*/
module.exports = class RequestContext {
constructor(request, cfg) {
// todo: consider using lodash.defaultsDeep
const req = { ...request, ...cfg.requestOverride };
// see https://github.com/nodejs/node/issues/36550
const req = {
...request,
get headers() { return request.headers; },
get trailers() { return request.trailers; },
...cfg.requestOverride,
};
if (cfg.requestOverride && cfg.requestOverride.headers) {
req.headers = { ...request.headers, ...cfg.requestOverride.headers };
}
Expand Down

0 comments on commit cbec17b

Please sign in to comment.