Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-server
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- angular, typescript, vite
- Área
- build-system, cli
Línea de trabajo
Compara packages/angular/build/src/builders/dev-server/schema.json con packages/angular_devkit/build_angular/src/builders/dev-server/schema.json, centrándote en las definiciones de allowedHosts y en el manejo relacionado de las opciones de dev-server. Confirma la compatibilidad prevista con el comportamiento existente de disableHostCheck y, después, verifica que @angular/build:dev-server acepte un array de nombres de host a través de la CLI sin romper la opción all-hosts compatible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 16 h 21 min
- PR fusionados (30 d)
- 170
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de angular/angular-cli
-
area: @angular/build gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
angular/angular-cli#34129 ·
-
Support aube as package manager Abiertoarea: @angular/cli gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
angular/angular-cli#34057 ·
-
area: @angular/cli gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
angular/angular-cli#33055 · 1 comentario · 3 reacciones ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 asignado ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 asignado ·
Todos los issues de angular/angular-cli
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Add: Star Sports 2 Telugu HD Abiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100