Skip to content

feat(react-start-api-routes): Write the matched route path as unenumerable to request object #3607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/start-api-routes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down