refactor(server)!: move correlationId to X-Correlation-ID response header (#28139)

This commit is contained in:
Timon
2026-04-28 19:07:39 +02:00
committed by GitHub
parent 2624f3884f
commit 96b6165bd3
5 changed files with 6 additions and 29 deletions
@@ -20,14 +20,16 @@ export class GlobalExceptionFilter implements ExceptionFilter<Error> {
const response = ctx.getResponse<Response>();
const { status, body } = this.fromError(error);
if (!response.headersSent) {
response.status(status).json({ ...body, statusCode: status, correlationId: this.cls.getId() });
response.header('X-Correlation-ID', this.cls.getId());
response.status(status).json({ ...body, statusCode: status });
}
}
handleError(res: Response, error: Error) {
const { status, body } = this.fromError(error);
if (!res.headersSent) {
res.status(status).json({ ...body, statusCode: status, correlationId: this.cls.getId() });
res.header('X-Correlation-ID', this.cls.getId());
res.status(status).json({ ...body, statusCode: status });
}
}