Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Possible error in the logical flow of the middleware sub-stack example provided in the website. #2022

Nishant-Dwivedi started this conversation in Content
Discussion options

Description

Image

Expectations

I could be wrong but i think you need to either remove the bang in front of req.headers['x-auth'] or swap next('route') with next().

You must be logged in to vote

Replies: 2 comments

Comment options

Hi @Nishant-Dwivedi , thanks for suggesting. I think the current logic is correct though — the ! is intentional because we want to block requests that are missing the x-auth header.

Also, we use next('router') to skip the rest of the router if the header is missing, so it falls through to the 401 handler.

I think we need to improve our documentation on next().
Cc @expressjs/docs-wg

You must be logged in to vote
0 replies

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Converted from issue

This discussion was converted from issue #1870 on August 02, 2025 19:10.

AltStyle によって変換されたページ (->オリジナル) /