Skip to content

express 5 router wildcard does not work as documented #1408

Closed

Description

@david-gang

Hi,

The following does not work as written in the documentation:
https://expressjs.com/en/5x/api.html

app.all('*', requireAuthentication, loadUser)

This is because you are at a newer version of path-to-regexp

https://github.com/pillarjs/path-to-regexp#compatibility-with-express--4x

so please update the documentation because this works

app.all('(.*)', requireAuthentication, loadUser)

I think that also the migration doc should reflect this change.

Thanks

Activity

  1. david-gang commented on Mar 16, 2023

    @david-gang
    Author

    @dougwilson I could open a PR with the documentation changes. English is not my mother tongue so i would prefer that a native english speaker will review the PR. What do you think ?

  2. IamLizu commented on Aug 14, 2024

    @IamLizu
    Member

    Hey @david-gang 👋

    Thank you for your contribution 🎉

    You can start this, if you are still here, please respond and I think someone will assign this to you.

  3. david-gang commented on Aug 16, 2024

    @david-gang
    Author

    Hi,

    I am not longer using express actively.

    Sorry,

  4. IamLizu commented on Aug 16, 2024

    @IamLizu
    Member

    Hey @david-gang 👋

    Its fine.

    In that case, I willing to fix it.

    cc: @UlisesGascon

  5. self-assigned this
    on Aug 20, 2024
  6. IamLizu commented on Aug 22, 2024

    @IamLizu
    Member

    Quick question, I have noticed that express 5.0 is not using path-to-regex, not listed as dependency.. Why is that?

    Edit: It appears that express 5 is using router which is using path-to-regexp "3.2.0".

  7. IamLizu commented on Sep 1, 2024

    @IamLizu
    Member

    We already have PR for this which is ready to be landed,

  8. crandmck commented on Sep 2, 2024

    @crandmck
    Member

    Fixed by #1369

  9. osakdv commented on Jul 19, 2025

    @osakdv

    Still encountered issues using either '*' or '(.*)' - in Express 5, these throw a missing parameter name error and fail to parse properly.

    The route pattern i use that works fine is this:
    /^\/(?!api).*/

    app.all(/^\/(?!api).*/, requireAuthentication, loadUser)

    NOTE: This excludes all routes starting with /api - api related routes

  10. bjohansebas commented on Jul 19, 2025

    @bjohansebas
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

5.xDocs for 5.x version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions