Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
jagobagascon opened this issue Jul 18, 2024 · 1 comment · Fixed by #28072
Closed
1 task

Comments

@jagobagascon
Copy link

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.

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 18, 2024
Added handling to ensure trailing slashes on static files do not disregard query strings.

Closes angular#28071
alan-agius4 added a commit that referenced this issue Jul 18, 2024
Added handling to ensure trailing slashes on static files do not disregard query strings.

Closes #28071
alan-agius4 added a commit that referenced this issue Jul 18, 2024
Added handling to ensure trailing slashes on static files do not disregard query strings.

Closes #28071

(cherry picked from commit 6d69375)
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants