Skip to content

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

Closed

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.

Activity

  1. added a commit that references this issue on Jul 18, 2024
    7297f47
  2. added 2 commits that reference this issue on Jul 18, 2024
    6d69375
    d868270
  3. angular-automatic-lock-bot commented on Aug 18, 2024

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

  4. locked and limited conversation to collaborators on Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    angular/build:dev-serverarea: @angular/buildfreq1: lowseverity3: brokentype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions