Skip to content

Server side router navigation with changes to query parameters not sending a redirect response #31482

@WizzardMaker

Description

@WizzardMaker

Command

run

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

When pushing a new navigation on server side only with:

await this.router.navigate([], {
  queryParams: {filter: 'test'},
  queryParamsHandling: 'merge', // remove to replace all query params by provided
  relativeTo: route
});

This does not result in a redirect response being sent to the browser, just a regular 200.

It seems like, in the check for whether the url change, the query parameters on finalUrl and initialUrl of the lastSuccessfulNavigation object are the same, which they shouldn't!

Minimal Reproduction

Reproduction code: https://github.com/WizzardMaker/angular-ssr-navigate-bug

Steps to reproduce in the project:

  1. Navigate to e.g. ´/?filter=a´
  2. See that server response is of status code 200, not any other redirect code

In short what the project does:
A route component triggers a router navigation in it's constructor like this:

if(isPlatformBrowser(inject(PLATFORM_ID))) return;

this.pendingTasks.run(async () => {
  await this.router.navigate([], {
    queryParams: {filter: 'test'},
    queryParamsHandling: 'merge', // remove to replace all query params by provided
    relativeTo: route
  })
})

Exception or Error


Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    


Angular CLI: 20.3.5
Node: 24.9.0
Package Manager: npm 11.6.0
OS: darwin arm64
    

Angular: 20.3.4
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-server, router

Package                      Version
------------------------------------
@angular-devkit/architect    0.2003.5
@angular-devkit/core         20.3.5
@angular-devkit/schematics   20.3.5
@angular/build               20.3.5
@angular/cli                 20.3.5
@angular/ssr                 20.3.5
@schematics/angular          20.3.5
rxjs                         7.8.2
typescript                   5.9.3

Anything else relevant?

This happens only on server side rendering on a standard node server and on ng serve. I don't quite know whether this behaviour changed between versions

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions