You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When constructing new Router({ prefix: '/api' }) and registering a root route with app.get('/', handler), the route should be reachable at the prefix path (/api and/or /api/). When the prefix accidentally ends with /, joining a child path should not produce a double slash.
resolvePrefixedPath('/', '/api') returns '/api' — the trailing slash is stripped. A handler registered at / under /api is unreachable from /api/; the request resolves to 404.
resolvePrefixedPath('/users', '/api/') returns '/api//users' — a literal double slash. Incoming requests to /api/users don't match the registered route id.
Code snippet
import{Router}from'@aws-lambda-powertools/event-handler/http';constapp=newRouter({prefix: '/api'});app.get('/',()=>({root: true}));// Request to /api/ → 404 Not Found (expected: 200 with { root: true })constapp2=newRouter({prefix: '/api/'});app2.get('/users',()=>({users: []}));// Internally registers GET:/api//users; request to /api/users → 404
Steps to Reproduce
Construct a Router with prefix: '/api' and register a handler at '/'.
Resolve a request for /api/.
Observe statusCode: 404.
Repeat with prefix: '/api/' and path: '/users'; observe the registered route id contains //.
Or run the failing test: npx vitest --run tests/unit/http/bugHunt.test.ts -t "Bug 5" from packages/event-handler/.
Possible Solution
No response
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
22.x
Packaging format used
npm
Execution logs
(not applicable — bug is reproducible from a unit test)
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
fix(event-handler): normalize prefix and request trailing slashes in …
powertools-for-aws-oss-automation commentedon May 27, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.