Skip to content

serve: trailing slash added to static files does not take query string into account #28071

Closed
@jagobagascon

Description

@jagobagascon

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

This is more or less a continuation of #27949. I was testing the fix for that issue in Angular 18.1.0 and found that it is still not working. And since I cannot reopen that issue I'm writing this new one.

Whenever I try to access a static file without a trailing slash, angular returns a redirect to the same path with a trailing backslash.

Get: /oauth2redirect

Status: 301
location: /oauth2redirect/

But if the path contains a query string, then the trailing backslash is added to the end of the query string:

Get: /oauth2redirect?code=xxx&scope=yyy&state=zzz

Status: 301
location: /oauth2redirect?code=xxx&scope=yyy&state=zzz/

So I end up in an infinite redirect loop that ends with a ERR_TOO_MANY_REDIRECTS error and the following URI:

/oauth2redirect?code=xxx&scope=yyy&state=zzz///////////////////////////////////////////////////////////////////////

Minimal Reproduction

The same used in #27949. Just add some query string parameter to the static file.

Exception or Error

No response

Your Environment

Angular CLI: 18.1.0
Node: 18.20.3
Package Manager: npm 10.8.1
OS: darwin arm64

Angular: 18.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0
@angular-devkit/build-angular   18.1.0
@angular-devkit/core            18.1.0
@angular-devkit/schematics      18.1.0
@schematics/angular             18.1.0
rxjs                            7.8.1
typescript                      5.5.3
zone.js                         0.14.7

Anything else relevant?

Pinging @alan-agius4 as you are already familiar with the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions