fix(@angular/ssr): support custom headers in redirect responses [20]#32779
Merged
dgp1130 merged 3 commits intoangular:20.3.xfrom Mar 17, 2026
Merged
fix(@angular/ssr): support custom headers in redirect responses [20]#32779dgp1130 merged 3 commits intoangular:20.3.xfrom
dgp1130 merged 3 commits intoangular:20.3.xfrom
Conversation
Updated the INVALID_PREFIX_REGEX to ensure that prefixes starting with a backslash are considered invalid. Previously, only multiple slashes or dot segments were explicitly disallowed at the start. Also updated the associated validation error message and unit tests to reflect this change.
There was a problem hiding this comment.
Code Review
This pull request refactors the createRedirectResponse function into its own utility file packages/angular/ssr/src/utils/redirect.ts and enhances it to support custom headers in redirect responses. The changes are well-structured and include corresponding updates to call sites and new tests. I've found a small issue with how the Vary header is being constructed which could lead to duplicate values. My suggestion addresses this to make the logic more robust.
Updates createRedirectResponse to accept an optional Record<string, string> of headers, allowing custom headers to be merged into the redirect response. The Location and Vary: X-Forwarded-Prefix headers are automatically set to ensure correct routing and proxy behavior. AngularServerApp now passes relevant headers from the matched route or response context when creating a redirect.
dc703c5 to
c062207
Compare
Refactors the `createRedirectResponse` function to use a `Set` for constructing the `Vary` header. This ensures that `X-Forwarded-Prefix` is always present exactly once, and that existing `Vary` values from provided headers are correctly parsed, deduplicated, and preserved. Updates the associated unit tests to reflect the new header order and verify the deduplication logic.
dgp1130
approved these changes
Mar 17, 2026
Collaborator
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.