I have this setup:
import http from "http";
import FindMyWay from "find-my-way";
const router = FindMyWay({
defaultRoute: (req, res) => {
res.statusCode = 404;
res.end(JSON.stringify({ message: "Not Found" }));
},
});
router.on("GET", "/:id", (req, res, params) => {
res.end(JSON.stringify(params));
});
const server = http.createServer((req, res) => {
router.lookup(req, res);
});
server.listen(3000);
When I hit /, I expect defaultRoute to handle it since there's no / route registered. Instead my /:id handler fires with params.id = undefined.
curl http://localhost:3000
# Expected: 404 from defaultRoute
# Actual: {} — /:id handler called with id = undefined
The only workaround I found is manually registering a / route, which feels wrong when defaultRoute already exists for this purpose.
find-my-way version: ^9.5.0
- Node.js version: v24.14.1
I have this setup:
When I hit
/, I expectdefaultRouteto handle it since there's no/route registered. Instead my/:idhandler fires withparams.id = undefined.The only workaround I found is manually registering a
/route, which feels wrong whendefaultRoutealready exists for this purpose.find-my-wayversion: ^9.5.0