diff --git a/packages/rest/src/http-handler.ts b/packages/rest/src/http-handler.ts index 03e3be4ba1e7..2406df1526f8 100644 --- a/packages/rest/src/http-handler.ts +++ b/packages/rest/src/http-handler.ts @@ -4,6 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Context} from '@loopback/core'; +import {MIDDLEWARE_CONTEXT} from '@loopback/express'; import { ComponentsObject, ControllerSpec, @@ -109,6 +110,11 @@ export class HttpHandler { this._serverConfig, ); + // Set the request context as a property of Express request object so that + // downstream Express native integration can access `RequestContext` + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (request as any)[MIDDLEWARE_CONTEXT] = requestContext; + const sequence = await requestContext.get( RestBindings.SEQUENCE, );