8000 Cannot mount more than one subapp on the same path · Issue #159 · lukeed/polka · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Cannot mount more than one subapp on the same path #159
Open
@talentlessguy

Description

@talentlessguy

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

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

$ curl localhost:3000/api/v1/product
product

Same code but with Express v4 returns the expected result.

Actual result

$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0