Skip to content

fix(req): normalize forwarded protocol casing#7330

Open
lin-hongkuan wants to merge 1 commit into
expressjs:masterfrom
lin-hongkuan:codex/express-protocol-lowercase
Open

fix(req): normalize forwarded protocol casing#7330
lin-hongkuan wants to merge 1 commit into
expressjs:masterfrom
lin-hongkuan:codex/express-protocol-lowercase

Conversation

@lin-hongkuan

@lin-hongkuan lin-hongkuan commented Jun 24, 2026

Copy link
Copy Markdown

This normalizes trusted X-Forwarded-Proto values to lowercase before exposing req.protocol, so req.secure handles HTTPS the same as https.

The regression tests cover both req.protocol and req.secure with uppercase forwarded protocol input.

Validation:

  • npx mocha --require test/support/env --check-leaks test/req.protocol.js test/req.secure.js
  • npm run lint
  • git diff --check

AI-assisted: Codex helped prepare this focused change; I reviewed the diff and ran the validation above before submitting.

@bjohansebas bjohansebas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest evaluating this for Express 6. The closest guidance we have is RFC 3986, Section 3.1, which allows both http and HTTP, although the lowercase form is still the preferred canonical form.

There isn't an issue requesting this, and this suggestion came purely from AI, so I'll leave it open as something to consider in the future.
https://www.rfc-editor.org/rfc/rfc3986.html#section-3.1

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants