fix: 在处理异常的中间件中未正确处理serializeException返回的headers
This commit is contained in:
parent
fc5f551cab
commit
96d4337b59
|
|
@ -204,8 +204,12 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
||||||
? err
|
? err
|
||||||
: new types_1.OakException(serverConfiguration?.internalExceptionMask ||
|
: new types_1.OakException(serverConfiguration?.internalExceptionMask ||
|
||||||
ExceptionMask);
|
ExceptionMask);
|
||||||
const { body } = connector.serializeException(exception, request.headers, request.body);
|
const { body, headers } = connector.serializeException(exception, request.headers, request.body);
|
||||||
ctx.response.body = body;
|
ctx.response.body = body;
|
||||||
|
// headers 要拼上
|
||||||
|
Object.keys(headers || {}).forEach(key => {
|
||||||
|
ctx.set(key, headers?.[key]);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -251,12 +251,16 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
||||||
serverConfiguration?.internalExceptionMask ||
|
serverConfiguration?.internalExceptionMask ||
|
||||||
ExceptionMask
|
ExceptionMask
|
||||||
);
|
);
|
||||||
const { body } = connector.serializeException(
|
const { body, headers } = connector.serializeException(
|
||||||
exception,
|
exception,
|
||||||
request.headers,
|
request.headers,
|
||||||
request.body
|
request.body
|
||||||
);
|
);
|
||||||
ctx.response.body = body;
|
ctx.response.body = body;
|
||||||
|
// headers 要拼上
|
||||||
|
Object.keys(headers || {}).forEach(key => {
|
||||||
|
ctx.set(key, headers?.[key])
|
||||||
|
})
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue