File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,18 @@ async function serverProxy({
6363 const apiCount = tool . file . fileStore ( global . config . _store ) . updateApiCount ( )
6464 const apiId = tool . hex . string10to62 ( apiCount )
6565 req . apiId = apiId
66- const cloneDeep = require ( `lodash.clonedeep` )
67- const newReq = cloneDeep ( req ) // 如果不 cloneDeep, 那么 req.body 到 send 回调中会被改变
66+
67+ // 只拷贝必要的字段,避免深拷贝整个req对象
68+ const newReq = {
69+ method : req . method ,
70+ url : req . url ,
71+ originalUrl : req . originalUrl ,
72+ headers : { ...req . headers } , // 浅拷贝headers
73+ body : req . body ? JSON . parse ( JSON . stringify ( req . body ) ) : undefined , // 只深拷贝body
74+ query : { ...req . query } , // 浅拷贝query
75+ params : { ...req . params } , // 浅拷贝params
76+ apiId : apiId
77+ }
6878 const oldSend = res . send
6979 res . send = ( data = `` ) => {
7080 let buffer = undefined
You can’t perform that action at this time.
0 commit comments