3

If I have two routes:

app.get('/example/:param');
app.get('/example/url');

Is there a way to stop a request to https://domainname.com:3000/example/url being treated as https://domainname.com:3000/example with req.params.param = "url"

Or should I just change the route names?!

barro32
  • 2,559
  • 23
  • 36

2 Answers2

4

The simplest solution would be to reverse the order of the app.get calls.

See also this answer for more approaches.

Community
  • 1
  • 1
Aleph Aleph
  • 5,215
  • 2
  • 13
  • 28
0

Your approach is not REST-ful and thus epxress.js will behave strangely. Change your paths so you no longer overload a path.

Clemens Himmer
  • 1,340
  • 2
  • 13
  • 26