OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet commits / 8fc0974

Fix routing: Use startsWith for all routes to support POST with path params
CRITICAL FIX: POST /api/contacts/:id/addresses was failing with "route not found" Before: - POST routes used exact match only - req.url=/api/contacts/123/addresses didn't match routePath=/api/contacts/ After: - All routes (GET and POST) use startsWith - Parse path params by splitting remaining path - Pass params as spread arguments to handler This fixes: - Adding Ethereum address to contact (POST /api/contacts/:id/addresses) - Removing address from contact (DELETE /api/contacts/:id/addresses/:chain) User report: "if i paste storyteller's eth address into the first contact it still fails with route not found" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
8fc0974d31b00e5a164ce9478418c310f39c28c6
by plankatron <fleeky@gmail.com> · 2026-01-27T22:48:18.000Z

Changed files (1) +5 -6

wallet-server.cjs +5 -6
……@@ -1941,15 +1941,14 @@ async function startServer() {
19411941 for (const [routeKey, handler] of Object.entries(routes)) {
19421942 const [method, routePath] = routeKey.split(' ')
19431943
1944 // For POST routes, match exactly; for GET routes with params, use startsWith
1945 const isMatch = (method === 'POST')
1946 ? (req.method === method && req.url === routePath)
1947 : (req.method === method && req.url.startsWith(routePath))
1944 // Use startsWith for all routes to support path parameters
1945 const isMatch = req.method === method && req.url.startsWith(routePath)
19481946
19491947 if (isMatch) {
1950 // Extract parameter (e.g., chain from /api/balance/bitcoin)
1948 // Extract parameters (e.g., :id/addresses from /api/contacts/:id/addresses)
19511949 const param = req.url.substring(routePath.length)
1952 await handler(req, res, param)
1950 const params = param ? param.split('/').filter(p => p) : []
1951 await handler(req, res, ...params)
19531952 handled = true
19541953 break
19551954 }