Skip to content

fix(@angular/ssr): preserve response headers during redirect#33476

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-33473
Open

fix(@angular/ssr): preserve response headers during redirect#33476
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-33473

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Previously, when a redirect was triggered, any custom headers (such as cookies or cache control) configured on the RESPONSE_INIT object by components or guards were lost because the redirect response was created with the default headers only.

Closes #33473

@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 updates the Angular SSR application to pass headers from responseInit to the redirect response, and adds corresponding tests to verify custom redirect headers. A review comment suggests avoiding Object.fromEntries because it can lose duplicate headers (such as multiple Set-Cookie headers), recommending instead to cast and pass responseInit.headers directly.

Comment thread packages/angular/ssr/src/app.ts Outdated
@alan-agius4 alan-agius4 force-pushed the fix-33473 branch 3 times, most recently from a4f3fd7 to 299ab00 Compare June 26, 2026 11:05
@alan-agius4 alan-agius4 requested a review from clydin June 26, 2026 11:05
@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 Jun 26, 2026
@alan-agius4

This comment was marked as resolved.

@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 updates the Angular SSR redirect logic to support and pass Headers objects from responseInit.headers during redirects, accompanied by test coverage. Feedback suggests reverting the check that avoids cloning Headers instances, as natively cloning them via new Headers(headers) prevents potential side effects from mutating shared header objects.

Comment thread packages/angular/ssr/src/utils/redirect.ts
Previously, when a redirect was triggered, any custom headers (such as cookies or cache control) configured on the RESPONSE_INIT object by components or guards were lost because the redirect response was created with the default headers only.

Closes angular#33473
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: @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.

[@angular/ssr] RESPONSE_INIT headers are ignored during redirects returned by UrlTree guards

1 participant