Skip to content

SSR causes 302 redirects to normalized URL #33053

Closed

Description

@kon72

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

Previously someone pointed out that SSR causes lots of 302 redirects (#31881).
The fix landed in #31883 but we are still facing the similar issue for other URL patterns.
I expect that Angular server returns 200 OK and then URL normalization happens solely on the client side.

  • /?empty redirects to /?empty=
  • /?scope=email+profile redirects to /?scope=email%20profile
  • /?bbb=1&aaa=2&bbb=3 redirects to /?bbb=1&bbb=3&aaa=2
  • //foo redirects to /foo

Minimal Reproduction

ng serve and access to URLs above

export const serverRoutes: ServerRoute[] = [
  {
    path: '**',
    renderMode: RenderMode.Server,
  },
];

Exception or Error


Your Environment

Angular CLI       : 21.2.8
Angular           : 21.2.10
Node.js           : 24.15.0
Package Manager   : pnpm 10.26.1
Operating System  : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.2.8            │ ^21.2.8           │
│ @angular/cdk              │ 21.2.8            │ ^21.2.8           │
│ @angular/cli              │ 21.2.8            │ ^21.2.8           │
│ @angular/common           │ 21.2.10           │ ^21.2.10          │
│ @angular/compiler         │ 21.2.10           │ ^21.2.10          │
│ @angular/compiler-cli     │ 21.2.10           │ ^21.2.10          │
│ @angular/core             │ 21.2.10           │ ^21.2.10          │
│ @angular/forms            │ 21.2.10           │ ^21.2.10          │
│ @angular/material         │ 21.2.8            │ ^21.2.8           │
│ @angular/platform-browser │ 21.2.10           │ ^21.2.10          │
│ @angular/platform-server  │ 21.2.10           │ ^21.2.10          │
│ @angular/router           │ 21.2.10           │ ^21.2.10          │
│ @angular/ssr              │ 21.2.8            │ ^21.2.8           │
│ rxjs                      │ 7.8.2             │ ^7.8.2            │
│ typescript                │ 5.9.3             │ ^5.9.3            │
│ vitest                    │ 4.1.4             │ ^4.1.4            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Activity

  1. alan-agius4 commented on Apr 25, 2026

    @alan-agius4
    Collaborator

    This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

    You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

    This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

  2. kon72 commented on Apr 25, 2026

    @kon72
    Author

    Hi @alan-agius4 ,

    I created a minimal repro for this issue: https://github.com/kon72/angular-ssr-redirect-repro

    npm i
    npm run start
    
    curl -I 'http://localhost:4200/?empty'
    curl -I 'http://localhost:4200/?scope=email+profile'
    curl -I 'http://localhost:4200/?bbb=1&aaa=2&bbb=3'
    curl -I 'http://localhost:4200//foo'

    All four requests should result in 302 redirect. (This is curl with HEAD method for brevity, but the same happens with browser requests.)

  3. self-assigned this
    on Apr 27, 2026
  4. added theissue type on Apr 27, 2026
  5. added 4 commits that reference this issue on Apr 27, 2026
    8f9cd4b
    ec09293
    128ff68
    c34c569
  6. added a commit that references this issue on Apr 28, 2026
    0dc8a44
  7. angular-automatic-lock-bot commented on May 29, 2026

    @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.

  8. locked and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions