Cannot mount more than one subapp on the same path
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 176
- PR merge metrics
- No merged PRs in 30d
Description
## Description
When trying to request a route from the second subapp mounted on the same path, it returns 404.
This happens because the first subapp responds with 404 (e.g. calls no match handler) and therefore doesn't switch to the next app, resulting in 404 even though the route is present in another app.
## Code
```js
import App from 'polka'
const router = App()
router.get('/upload', (req, res) => res.end('upload'))
const router2 = App()
router2.get('/product', (req, res) => res.end('product'))
const app = App()
app.use('/api/v1', router, router2)
app.listen(3000, () => console.log(`Started on :3000`))
```
## Expected result
```sh
$ curl localhost:3000/api/v1/product
product
```
Same code but with Express v4 returns the expected result.
## Actual result
```sh
$ curl localhost:3000/api/v1/product
Not Found
```
## Info
- polka: `1.0.0-next.11`
- Node.js: 15.8
- `uname -r`: 5.10.15-1-MANJARO
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the two subapps passed to app.use('/api/v1', router, router2), then trace how the first subapp handles a 404 before the second is reached. Compare the behavior with the reported Express v4 result. Done means the /api/v1/product request reaches router2 while existing unmatched-route behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100