diff --git a/src/middleware/tracing.middleware.ts b/src/middleware/tracing.middleware.ts index f014e64..a2cf990 100644 --- a/src/middleware/tracing.middleware.ts +++ b/src/middleware/tracing.middleware.ts @@ -1,8 +1,8 @@ import { Request, Response, NextFunction } from 'express'; -import { v4 as uuidv4 } from 'uuid'; +import * as crypto from 'crypto'; export const tracingMiddleware = (req: Request, res: Response, next: NextFunction) => { - req.headers['x-correlation-id'] = req.headers['x-correlation-id'] || uuidv4(); - res.setHeader('x-correlation-id', req.headers['x-correlation-id']); + req.headers['x-correlation-id'] = req.headers['x-correlation-id'] || crypto.randomUUID(); + res.setHeader('x-correlation-id', req.headers['x-correlation-id'] as string); next(); };