Skip to content

Node.js based forum software built for the modern web

refactor: copy session/headers when building req

Barış Soner Uşaklıe4a0160e085a
diff --git a/src/api/helpers.js b/src/api/helpers.js
index 168e5539b6..7df860a569 100644
--- a/src/api/helpers.js
+++ b/src/api/helpers.js
@@ -35,7 +35,7 @@ exports.buildReqObject = (req, payload) => {
params: req.params,
method: req.method,
body: payload || req.body,
- session: session,
+ session: JSON.parse(JSON.stringify(session)),
ip: req.ip,
host: host,
protocol: encrypted ? 'https' : 'http',
@@ -44,7 +44,7 @@ exports.buildReqObject = (req, payload) => {
path: referer.slice(referer.indexOf(host) + host.length),
baseUrl: req.baseUrl,
originalUrl: req.originalUrl,
- headers: headers,
+ headers: { ...headers },
};
};