Skip to content

refactor(@angular/ssr): reuse ɵisHostAllowed from @angular/platform-server - #34793

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:refactor/ssr-use-platform-server-is-host-allowed
Nov 30, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:refactor/ssr-use-platform-server-is-host-allowed

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

@angular/ssr maintains a duplicate isHostAllowed implementation in packages/angular/ssr/src/utils/validation.ts instead of reusing ɵisHostAllowed exported by @angular/platform-server, risking drift with changes in @angular/platform-server (such as angular/angular#72203).

What is the new behavior?

  • Replace the duplicate isHostAllowed implementation in packages/angular/ssr/src/utils/validation.ts with ɵisHostAllowed from @angular/platform-server.
  • Extract framework-independent HTTP/proxy header helpers into packages/angular/ssr/src/utils/headers.ts so packages/angular/ssr/node/src/request.ts and pure-Node tests do not pull in @angular/platform-server.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • Verified server.mjs bundle output: @angular/core, Domino, xhr2, and rxjs remain completely tree-shaken out in production builds.
  • Once fix(platform-server): support ports in allowedHosts angular#72203 merges and cross-repo deps update, a follow-up can pass the effective port as the 3rd argument from validateUrl and verifyHostAllowed.

…erver

Replace the duplicate local `isHostAllowed` implementation in `@angular/ssr` with `ɵisHostAllowed` from `@angular/platform-server` so host allowlist matching stays consistent across both packages.

Extract the framework-independent HTTP/proxy header helpers into `src/utils/headers.ts` so `node/src/request.ts` and its pure-Node unit tests do not pull in `@angular/platform-server`.

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

Copy link
Copy Markdown

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 the codebase by moving header-related utility functions from packages/angular/ssr/src/utils/validation.ts to a new file packages/angular/ssr/src/utils/headers.ts to improve modularity. The reviewer identified a potential bug in the getFirstHeaderValue function where passing an empty array results in an empty string instead of undefined, which could cause issues with downstream nullish coalescing. A code suggestion was provided to handle array inputs explicitly and improve the function's robustness.

@alan-agius4
alan-agius4 requested a review from clydin November 26, 2026 09:15
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Nov 26, 2026
@alan-agius4 alan-agius4 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 Nov 30, 2026
@alan-agius4
alan-agius4 merged commit 612cde0 into angular:main Nov 30, 2026
43 checks passed
@alan-agius4
alan-agius4 deleted the refactor/ssr-use-platform-server-is-host-allowed branch November 30, 2026 16:03
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

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: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants