fix(server): set reqeust-id on ClsModule setup (#9829)

This commit is contained in:
fengmk2
2025-01-21 10:15:37 +00:00
parent b6a8d644f8
commit 54dd131f4e
4 changed files with 8 additions and 18 deletions
@@ -1,16 +0,0 @@
import { NextFunction, Request, Response } from 'express';
import { ClsServiceManager } from 'nestjs-cls';
import onHeaders from 'on-headers';
export const responseRequestIdHeader = (
_req: Request,
res: Response,
next: NextFunction
) => {
onHeaders(res, () => {
const requestId = ClsServiceManager.getClsService().getId();
res.setHeader('X-Request-Id', requestId);
});
next();
};