diff --git a/backend/src/middlewares/http-context.middleware.ts b/backend/src/middlewares/http-context.middleware.ts index da02bfe..3fd29fc 100644 --- a/backend/src/middlewares/http-context.middleware.ts +++ b/backend/src/middlewares/http-context.middleware.ts @@ -2,14 +2,13 @@ import { NextFunction, Request, Response } from 'express'; import { container } from '../config/dependency-injector.config.js'; import { HttpContextService } from '../services/index.js'; -export const httpContextMiddleware = (req: Request, res: Response, next: NextFunction) => { +export const httpContextMiddleware = (req: Request, _res: Response, next: NextFunction) => { + if (req.path === '/livekit/webhook') { + // Skip setting context for LiveKit webhooks + return next(); + } + const httpContextService = container.get(HttpContextService); httpContextService.setContext(req); - - // Clear context after response is finished - res.on('finish', () => { - httpContextService.clearContext(); - }); - next(); };