Skip to content

fix(@angular/ssr): add support for configuring trusted proxy headers via environment variable#33273

Open
dgp1130 wants to merge 1 commit into
angular:19.2.xfrom
dgp1130:trust-proxy-headers-env-v19
Open

fix(@angular/ssr): add support for configuring trusted proxy headers via environment variable#33273
dgp1130 wants to merge 1 commit into
angular:19.2.xfrom
dgp1130:trust-proxy-headers-env-v19

Conversation

@dgp1130
Copy link
Copy Markdown
Collaborator

@dgp1130 dgp1130 commented May 29, 2026

This is a v19 port of #33056.

Adds support for configuring trusted proxy headers via the NG_TRUST_PROXY_HEADERS environment variable in AngularNodeAppEngine. This allows users to specify which proxy headers (such as X-Forwarded-Host) should be trusted when running the server-side application behind a reverse proxy, without needing to modify the application code. The environment variable accepts a comma-separated list of header names. If the NG_TRUST_PROXY_HEADERS environment variable is set and contains non-empty values, it will take precedence over the trustProxyHeaders option provided programmatically in the AngularNodeAppEngine constructor options.

(cherry picked from commit 126b19b)

…via environment variable

Adds support for configuring trusted proxy headers via the `NG_TRUST_PROXY_HEADERS` environment variable in `AngularNodeAppEngine`.
This allows users to specify which proxy headers (such as `X-Forwarded-Host`) should be trusted when running the server-side application behind a reverse proxy, without needing to modify the application code. The environment variable accepts a comma-separated list of header names.
If the `NG_TRUST_PROXY_HEADERS` environment variable is set and contains non-empty values, it will take precedence over the `trustProxyHeaders` option provided programmatically in the `AngularNodeAppEngine` constructor options.

(cherry picked from commit 126b19b)
@dgp1130 dgp1130 requested a review from alan-agius4 May 29, 2026 15:51
@dgp1130 dgp1130 added action: review The PR is still awaiting reviews from at least one requested reviewer target: lts This PR is targeting a version currently in long-term support area: @angular/ssr labels May 29, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors environment options parsing and introduces support for the NG_TRUST_PROXY_HEADERS environment variable. However, the changes alter the behavior of allowedHosts by overriding programmatic options with environment variables instead of merging them, which could cause breaking changes. Additionally, NG_TRUST_PROXY_HEADERS should be updated to correctly parse boolean values ('true'/'false') instead of treating them as single-item string arrays.

Comment thread packages/angular/ssr/node/src/environment-options.ts
Comment thread packages/angular/ssr/node/src/app-engine.ts
Comment thread packages/angular/ssr/node/src/common-engine/common-engine.ts
@dgp1130 dgp1130 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/ssr target: lts This PR is targeting a version currently in long-term support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants