Repository navigation
Description
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
We are migrating our project to Angular's new build system. It is the preferred option for new projects and we think migrating to it is a good idea. But we have found a small issue with how the static assets are served compared to the previous browser builder.
Our application requires a bunch of static files to work, and one of the html files is accessed using the parent folder name without a trailing slash: localhost:4200/oauth2redirect. Using the previous builder this was loading the oauth2redirect/index.html file.
After migrating to the new application builder, this same URI throws the following error:
Error: NG04002: Cannot match any routes. URL Segment: 'oauth2redirect'
This can be fixed by adding a trailing slash to the URI (localhost:4200/oauth2redirect/). But this would require updating our OAuth redirect uri. And since this is something already supported by other tools and platforms (Google Cloud Buckets for example), I think it may be a good idea to support it here as well.
Minimal Reproduction
Add some static index.html to an angular project:
src/
app/...
static/
oauth2redirect/
index.html
// angular.json
"assets": [
{
"glob": "**/*",
"input": "src/static",
"output": "/"
}
]Serve the app
ng serveAnd try to load the file by using its parent folder.
All three URIs work with previous browser builder. And the first one fails with the new application builder.
localhost:4200/oauth2redirect # => error
localhost:4200/oauth2redirect/ # => loads the file
localhost:4200/oauth2redirect/index.hmtl # => loads the fileException or Error
No response
Your Environment
Angular CLI: 17.3.8
Node: 18.20.3
Package Manager: npm 10.8.1
OS: darwin arm64
Angular: 17.3.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1703.8
@angular-devkit/build-angular 17.3.8
@angular-devkit/core 17.3.8
@angular-devkit/schematics 17.3.8
@angular/cdk 17.3.10
@angular/cli 17.3.8
@angular/material 17.3.10
@schematics/angular 17.3.8
rxjs 7.8.1
typescript 5.3.3
zone.js 0.14.4
Anything else relevant?
No response
Activity
alan-agius4 commentedon Jun 27, 2024
I had a quick look at this, and what happens here is that express static will redirect to the
/when the pathname is a directory by default but vite does not.fix(@angular/build): redirect to path with trailing slash for asset d…
fix(@angular/build): redirect to path with trailing slash for asset d…
fix(@angular/build): redirect to path with trailing slash for asset d…
fix(@angular/build): redirect to path with trailing slash for asset d…
fix(@angular/build): redirect to path with trailing slash for asset d…
fix(@angular/build): redirect to path with trailing slash for asset d…
jagobagascon commentedon Jun 28, 2024
Thank you for the quick fix!
angular-automatic-lock-bot commentedon Jul 29, 2024
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.