From f6263d727f35c044b4ff93c498c0fc1f17f31aa9 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 28 Feb 2025 13:54:15 +0100 Subject: [PATCH 1/2] feat(react-start-api-routes): Write the matched route path as unenumerable to request object --- packages/react-start-api-routes/src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-start-api-routes/src/index.ts b/packages/react-start-api-routes/src/index.ts index 9ee1fc8ac1..746ed7a4e6 100644 --- a/packages/react-start-api-routes/src/index.ts +++ b/packages/react-start-api-routes/src/index.ts @@ -334,6 +334,13 @@ export const defaultAPIFileRouteHandler: StartAPIHandlerCallback = async ({ return new Response('Not found', { status: 404 }) } + // Writing the matched route path to the request allows observability tools to group requests by the parameterized route. + Object.defineProperty(request, '_matchedRoutePath', { + value: match.routePath, + writable: true, + configurable: true, + }); + // The action is the route file that we need to import // which contains the possible handlers for the incoming request let action: APIRouteReturnType | undefined = undefined From 43ad6447dae5c068d9c758487ffb7d522d6127e4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:37:42 +0000 Subject: [PATCH 2/2] ci: apply automated fixes --- packages/start-api-routes/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/start-api-routes/src/index.ts b/packages/start-api-routes/src/index.ts index ce2aa5937a..4045c2f530 100644 --- a/packages/start-api-routes/src/index.ts +++ b/packages/start-api-routes/src/index.ts @@ -339,7 +339,7 @@ export const defaultAPIFileRouteHandler: StartAPIHandlerCallback = async ({ value: match.routePath, writable: true, configurable: true, - }); + }) // The action is the route file that we need to import // which contains the possible handlers for the incoming request