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
Angular CLI messes up proxy.conf.js regex proxy -settings passed to Vite when using esbuild.
^\\/(?!hui).* becomes \^\/(?!hui)\.[^/]*?\/?
Minimal Reproduction
Vite doesn't seem to support glob patterns in proxy.conf.js. It supports regular expressions which would do fine but Angular CLI proxy configuration normalization messes up regular expressions. Normalization is done here:
This step perhaps mistakenly treats regular expressions as globs:
// TODO: Consider upstreaming glob support
for (const key of Object.keys(normalizedProxy)) {
if (isDynamicPattern(key)) {
const { output } = parseGlob(key);
normalizedProxy[`^${output}$`] = normalizedProxy[key];
delete normalizedProxy[key];
}
}
Previously with @angular-devkit/build-angular:browser we had:
module.exports = [
{
context: "/internal-api",
target: "http://localhost:8082",
logLevel: "debug",
secure: false
},
{
context: "!/hui/**",
target: "http://localhost:8080",
logLevel: "debug",
secure: false
}
]
With @angular-devkit/build-angular:browser-esbuild something like this should be equivalent if the configuration would go to Vite without changes:
module.exports = {
"/internal-api": {
target: "http://localhost:8082",
secure: false,
},
"^\\/(?!hui).*": {
target: "http://localhost:8080",
secure: false
},
"^\\/$": {
target: "http://localhost:8080",
secure: false,
}
};
Exception or Error
No response
Your Environment
Angular CLI: 17.1.0
Node: 20.11.0
Package Manager: npm 10.2.4
OS: win32 x64
Angular: 17.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1701.0
@angular-devkit/build-angular 17.1.0
@angular-devkit/core 17.1.0
@angular-devkit/schematics 17.1.0
@schematics/angular 17.1.0
ng-packagr 17.1.1
rxjs 7.8.1
typescript 5.3.3
zone.js 0.14.3
Anything else relevant?
No response
Activity
fix(@angular-devkit/build-angular): do not process regular expression…
fix(@angular-devkit/build-angular): do not process regular expression…
fix(@angular-devkit/build-angular): do not process regular expression…
fix(@angular-devkit/build-angular): handle regular expressions in pro…
fix(@angular-devkit/build-angular): handle regular expressions in pro…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
fix(@angular-devkit/build-angular): correctly handle glob negation in…
clydin commentedon Jan 26, 2024
Both the negation configuration option and the regular expression option will be available in the next patch release.
So if preferred, you could leave the proxy configuration in its original form at that time.
fix(@angular-devkit/build-angular): handle regular expressions in pro…
fix(@angular-devkit/build-angular): handle regular expressions in pro…
fix(@angular-devkit/build-angular): handle regular expressions in pro…
ajkettun commentedon Feb 1, 2024
Thanks for the fix!
angular-automatic-lock-bot commentedon Mar 3, 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.