Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-server
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 74/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- angular, typescript, vite
- Domaine
- build-system, cli
Piste de recherche
Comparez packages/angular/build/src/builders/dev-server/schema.json avec packages/angular_devkit/build_angular/src/builders/dev-server/schema.json, en vous concentrant sur les définitions de allowedHosts et sur la gestion associée des options de dev-server. Confirmez la compatibilité prévue avec le comportement existant de disableHostCheck, puis vérifiez que @angular/build:dev-server accepte un tableau de noms d’hôtes via la CLI sans casser l’option all-hosts prise en charge.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
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
When using @angular-devkit/build-angular:dev-server I can use --allowedHosts parameter with array of hostnames, so my hostnames can be dynamic.
But when using @angular/build:dev-server the array of names is not recognized (only boolean type is passed instead?)
ng serve myproject --allowed-hosts "example.com"
"Error: Unknown argument: example.com"
Workaround:
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=example.com ng serve myproject
or hard code in the array format in angular.json like mentioned in https://github.com/angular/angular/issues/64104
Comparing the two builder i can see this difference if you "patch" @angular/build:dev-server's schema.json, then the command will work.
https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/builders/dev-server/schema.json
vs
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/dev-server/schema.json
"allowedHosts": {
+ "type": "array",
"description": "The hosts that the development server will respond to. This option sets the Vite option of the same name. For further details: https://vite.dev/config/server-options.html#server-allowedhosts",
"default": [],
+ "items": {
+ "type": "string"
+ }
- "oneOf": [
- {
- "type": "array",
- "description": "A list of hosts that the development server will respond to.",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "boolean",
- "description": "Indicates that all hosts are allowed. This is not recommended and a security risk."
- }
- ]
},
@see issue * PR for the devkit commit that added the option:
- https://github.com/angular/angular-cli/issues/13656
- https://github.com/angular/angular-cli/pull/15366
It note that @angular-devkit/build-angular:dev-server also has a (custom?) --disableHostCheck parameter which sets allowedHosts to true if passed, so then disable all hosts situation can be covered as schema no longer allows boolean, only array.
Not sure how to fix properly.
Minimal Reproduction
Exception or Error
Your Environment
-
Anything else relevant?
No response
- Langage dominant
- TypeScript
- Étoiles
- 27k
- Forks
- 11.8k
- Merge moyen
- 16 h 21 min
- PR mergées (30 j)
- 170
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de angular/angular-cli
-
area: @angular/cli gemini-triaged
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/angular-cli#33055 · 1 commentaire · 3 réactions ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 personne assignée ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 personne assignée ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34128 · 1 personne assignée ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34124 · 1 commentaire · 1 personne assignée ·
Toutes les issues de angular/angular-cli
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Ouvertebug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Client support matrix inclusion Ouverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
calcite-components needs triage refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Esri/calcite-design-system#15203 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
fullcalendar/fullcalendar#8106 ·