question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subapp overrides all paths, even the ones from original app

See original GitHub issue

Describe the bug

When a subapp is mounted on a path, all of the middlewares with the same path in the original app are ignored and return 404 because it’s being handled by a subapp.

To Reproduce

import { App } from '@tinyhttp/app'
import serveStatic from 'serve-static'
import sirv from 'sirv'
import path from 'path'

const app = new App()

const subapp = new App()

subapp.get('/',(req, res) => res.send('hello world'))


app.use('/', sirv('public'))
app.use('/', subapp)

app.listen(3000)
$ curl localhost:3000
hello world
$ curl localhost:3000/hello.txt
Not Found

Expected behavior

If subapp couldn’t find the handler with the request path, the original middleware should handle it instead.

$ curl localhost:3000
hello world
$ curl localhost:3000/hello.txt
I am a file

Versions

  • node: 15.4.0
  • @tinyhttp/app: 1.1.0

Additional context

#203

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
allcontributors[bot]commented, Dec 23, 2020

@talentlessguy

I’ve put up a pull request to add @calumk! 🎉

0reactions
talentlessguycommented, Dec 23, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Subapp overrides all paths, even the ones from original app
Describe the bug When a subapp is mounted on a path, all of the middlewares with the same path in the original app...
Read more >
Subapp overrides all paths, even the ones from original app #209
When a subapp is mounted on a path, all of the middlewares with the same path in the original app are ignored and...
Read more >
Sub Applications - Behind a Proxy - FastAPI
In this case, the original path /app will actually be served at /api/v1/app . Even though your application "thinks" it is serving at...
Read more >
yarn workspaces and lerna cause Invalid Hook call
Current behavior : In the container project, it works fine when I route to sub-app/foo . But when I route to sub-app I...
Read more >
Applications - Django documentation
When INSTALLED_APPS contains the dotted path to an application module, by default, if Django finds exactly one AppConfig subclass in the apps.py submodule, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found