Skip to content

Support Forwarded header (RFC 7239) alongside X-Forwarded-*#709

Merged
kitsonk merged 3 commits into
mainfrom
copilot/support-forwarded-header
Feb 22, 2026
Merged

Support Forwarded header (RFC 7239) alongside X-Forwarded-*#709
kitsonk merged 3 commits into
mainfrom
copilot/support-forwarded-header

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

  • Explore repository structure and understand existing X-Forwarded-* handling in request.ts
  • Implement Forwarded header (RFC 7239) parsing in request.ts
    • Added ForwardedEntry interface and module-level parseForwarded() helper
    • Added #forwarded cache field and #getForwarded() private method on Request
    • Updated get ips(): checks Forwarded: for=... first, falls back to X-Forwarded-For
    • Updated get url(): checks Forwarded: proto=... / Forwarded: host=... on first entry first, falls back to X-Forwarded-Proto / X-Forwarded-Host
    • Updated JSDoc on ip, ips, url to mention the new behaviour
  • Added 6 new tests in request.test.ts
  • Code review: addressed quoted-string RFC 7230 backslash unescaping and added host-trust comment
  • Style: expanded single-line if (!this.#proxy) return []; to multi-line form
  • CodeQL scan: 0 alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>Support Forwarded header as well as X-Forwarded-*</issue_title>
<issue_description>The header Forwarded replaces the legacy X-Forwarded-* headers and should be supported by oak.</issue_description>

<agent_instructions>Investigate how the Forwarded header is now common, but preserve legacy behaviour.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@kitsonk Actually wrong issue tagged.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: kitsonk <1282577+kitsonk@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Support Forwarded header alongside X-Forwarded-* Support Forwarded header (RFC 7239) alongside X-Forwarded-* Feb 20, 2026
Copilot AI requested a review from kitsonk February 20, 2026 23:59
Comment thread request.ts Outdated
.filter((part) => part.length > 0);
})()
: [];
if (!this.#proxy) return [];
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.

@copilot I really dislike single line if statements:

Suggested change
if (!this.#proxy) return [];
if (!this.#proxy) {
return [];
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 40bc983.

Co-authored-by: kitsonk <1282577+kitsonk@users.noreply.github.com>
Copilot AI requested a review from kitsonk February 22, 2026 03:00
Copy link
Copy Markdown
Member

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

LGTM

@kitsonk kitsonk marked this pull request as ready for review February 22, 2026 03:00
@kitsonk kitsonk merged commit be44d90 into main Feb 22, 2026
2 of 3 checks passed
@kitsonk kitsonk deleted the copilot/support-forwarded-header branch February 22, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Forwarded header as well as X-Forwarded-*

3 participants