Skip to content

SSR url normalization causes 302 redirects #31881

Description

@MarcoGlauser

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

With the introduction of #31497, we noticed higher CPU usage and looked at the logs. We noticed a lot of 302 redirects happening now that will cause 2 requests to be served instead of one.
Angular SSR is already slow, taking more than a second to answer requests. With the introduction of the redirects, the ssr server now has to compute two requests and end user latency doubles.

It looks like the internal url normalization of angular will issue redirects, where they're not necessary.

Minimal Reproduction

This url
/?email=xyz%40xyz.com
Will redirect to
/?email=xyz@xyz

Exception or Error


Your Environment

Angular CLI: 20.3.10
Node: 24.11.0
Package Manager: npm 11.6.1
OS: linux x64
    

Angular: 20.3.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------
@angular-devkit/architect         0.2003.10
@angular-devkit/core              20.3.10
@angular-devkit/schematics        20.3.10
@angular/build                    20.3.10
@angular/cdk                      20.2.13
@angular/cli                      20.3.10
@angular/material                 20.2.13
@angular/material-luxon-adapter   20.2.13
@angular/ssr                      20.3.10
@angular/youtube-player           20.2.13
@schematics/angular               20.3.10
typescript                        5.9.3
zone.js                           0.15.1

Anything else relevant?

No response

Activity

  1. added 2 commits that reference this issue on Nov 20, 2025
    e148be7
    077382c
  2. added theissue type on Nov 20, 2025
  3. self-assigned this
    on Nov 20, 2025
  4. stevengunneweg commented on Nov 20, 2025

    @stevengunneweg

    We experienced an issue with the same cause.

    Our application runs pages with a trailing slash, we have configured a redirect in our SSR server when a url without trailing slash is requested. As of v20.3.x we see a recursive redirect. This is caused by a change in renderAngular where redirectTo determination now uses stripTrailingSlash.

    Previously the url was not manipulated (const finalUrlStringified = finalUrl.toString();) but since 20.3.x this url has the trailing slash stripped (const finalUrl = [stripTrailingSlash(pathname), search, hash].join('');) without a means to configure it. The effect is that a 302 is given to the browser with a Location header where the trailing slash is stripped. Locally removing the stripTrailingSlash usage resolves the issue.

    It would be best if the stripping of trailing slash could be configured, though at the moment I would not know how this could best be achieved

  5. added 3 commits that reference this issue on Nov 20, 2025
    f75a209
    875d13d
    db2929b
  6. MarcoGlauser commented on Nov 21, 2025

    @MarcoGlauser
    Author

    Thank you @alan-agius4 for providing a quick fix :) Is there any chance this patch will be backported to v20?
    We can't upgrade to v21 yet because other libraries are not compatible yet.

    For now, we're side stepping this issue by configuring our reverse proxy to strip all url params and handle the trailing slash redirects directly instead of proxying the request.

  7. added a commit that references this issue on Nov 21, 2025
    3cac018
  8. added a commit that references this issue on Nov 21, 2025
    61a027d
  9. alan-agius4 commented on Nov 21, 2025

    @alan-agius4
    Collaborator

    Yes. this will be backported to version 20.

  10. added a commit that references this issue on Nov 21, 2025
    1f8cdce
  11. added a commit that references this issue on Nov 21, 2025
    1abe68a
  12. angular-automatic-lock-bot commented on Dec 22, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  13. locked and limited conversation to collaborators on Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions