Skip to content

Commit 11a7a26

Browse files
committed
fix: Parameter urls for API requests
1 parent 82318d2 commit 11a7a26

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
3131

3232
const url = `${req.url}`;
3333
// pull off query string, if any
34-
const reqPath = stripUrlQueryAndFragment(url);
34+
let reqPath = stripUrlQueryAndFragment(url);
35+
// Replace with placeholder
36+
if (req.query) {
37+
for (const [key, value] of Object.entries(req.query)) {
38+
reqPath = reqPath.replace(`${value}`, `[${key}]`);
39+
}
40+
}
3541

3642
// requests for pages will only ever be GET requests, so don't bother to include the method in the transaction
3743
// name; requests to API routes could be GET, POST, PUT, etc, so do include it there

0 commit comments

Comments
 (0)