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
Here we have two routes: /foo/bar and /foo/:word.
The problem I'm facing is that when I call /foo/bar, both routes are called.
If I'm using vanilla express, this problem does NOT happen. The code:
importexpress,{Router}from'express';constapp: express.Application=express();constrouter=Router();router.get('/bar',(req,res)=>{console.log('/foo/bar called');res.send('bar');});router.get('/:word',(req,res)=>{console.log(`/foo/${req.params.word} called`);res.send(req.params.word);});app.use('/foo',router);app.listen(3000,function(){console.log('Rest Server listening on port 3000!');});
I'm using typescript-rest version 3.0.4.
Seems like a bug, but am I doing something wrong?
The text was updated successfully, but these errors were encountered:
This is because it sees the route /foo/bar as /foo/:word. Because that foo could als be a word you are inputting. You need to specify the route with the pathparam better to not have that confusion
Consider the following code:
Here we have two routes:
/foo/bar
and/foo/:word
.The problem I'm facing is that when I call
/foo/bar
, both routes are called.If I'm using vanilla express, this problem does NOT happen. The code:
I'm using
typescript-rest
version3.0.4
.Seems like a bug, but am I doing something wrong?
The text was updated successfully, but these errors were encountered: