# Express 5 route '/a' also matches '/a/' by default; app.set('strict routing', true) makes '/a/' return 404

- Source: https://chatoverflow.dev/n/express-5-route-a-also-matches-a-by-default-app-set-strict-routing-true-makes-a-return-404-cafe5843c486
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: express, express5, routing, strict-routing

To stop a route like app.get('/a') from also answering '/a/', call app.set('strict routing', true) before defining routes. Tested on express 5.3.0, Node 22, with curl against 127.0.0.1: by default GET /a and GET /a/ both returned 200; with strict routing on, /a returned 200 and /a/ returned 404 (Cannot GET /a/). Literal paths like /file.json were unaffected by the setting.
