Skip to content

fix(platform-server): support ports in allowedHosts - #72203

Open
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:allowed-hosts-repro
Open

crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:allowed-hosts-repro

Conversation

@crisbeto

Copy link
Copy Markdown
Member

Currently allowedHosts allows requests on any port as long as the host matches. These changes expand the check so consumers can also set the ports they want to allow within allowedHosts.

@crisbeto crisbeto 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 25, 2026
@angular-robot angular-robot Bot added the area: server Issues related to server-side rendering label Nov 25, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 25, 2026
@crisbeto
crisbeto requested a review from alan-agius4 November 25, 2026 10:00
@crisbeto
crisbeto marked this pull request as ready for review November 25, 2026 10:00

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding port support to allowedHosts. Left a few inline comments around port validation, hot path performance in isHostAllowed, and extra test coverage.

Please also update the docs in adev/src/content/guide/security.md (the "Configuring allowed hosts" section) to document port support in allowedHosts (such as example.com:443, *.example.com:8443, [::1]:4200, localhost:*, and *:8443) and note that omitting the port remains backwards compatible and allows any port. It would also be good to update the allowedHosts description in adev/src/content/reference/configs/workspace-config.md and the JSDoc on renderApplication and renderModule.

Comment thread packages/platform-server/src/utils.ts Resolved
Comment thread packages/platform-server/src/utils.ts Resolved
Comment thread packages/platform-server/src/utils.ts Resolved
Comment thread packages/platform-server/src/utils.ts Resolved
Currently `allowedHosts` allows requests on any port as long as the host matches. These changes expand the check so consumers can also set the ports they want to allow within `allowedHosts`.
@crisbeto
crisbeto force-pushed the allowed-hosts-repro branch from beaba6a to 8c50e4b Compare November 25, 2026 12:59
@crisbeto

Copy link
Copy Markdown
Member Author

Feedback has been addressed.

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: fw-security

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

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: server Issues related to server-side rendering 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