-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix running ng serve (alt): Set allowed hosts via environment variable
#19691
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
Conversation
Vite now supports specifying allowed hosts as an `__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS`. Alternative fix to a1555af: Only overrides allowed hosts in the development environments that need it (i.e. Docker + TLS stack). See: https://vite.dev/config/server-options.html#server-allowedhosts See: vitejs/vite#19325
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR moves the Vite development server's allowed hosts configuration from the Angular build configuration to an environment variable approach, allowing for more flexible configuration in different deployment environments.
- Removes hardcoded
allowedHostsconfiguration fromangular.json - Adds environment variable
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTSto Docker TLS configuration - Includes a minor grammar fix in documentation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/angular.json | Removes hardcoded allowedHosts configuration for development target |
| docs/development/development-environment/docker/README.md | Corrects grammar in test documentation |
| docker/dev/tls/docker-compose.core-override.example.yml | Adds environment variable for allowed hosts and port mappings |
ng serve (alt): Set allowed hosts via environment variable
|
|
||
| frontend: | ||
| environment: | ||
| __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS: "openproject-assets.local" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that it's non-breaking for other users, could we specify this on the docker-compose.yml already? Then it would work out of the box for everyone using the default hostnames. If you want to use a different hostname, the override is still possible.
It seems to be fine to have these ports settings as well as __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS envvar set in docker-compose.yml directly. So, there is less to override to get your docker TLS dev stack working.
Developers will need to manually updated theiredit: not anymoredocker-compose.override.ymlon merging this PRVite now supports specifying allowed hosts as an
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS.Alternative fix to #19687 / a1555af: Only overrides allowed hosts in the development environments that need it (i.e. Docker + TLS stack).
See: https://vite.dev/config/server-options.html#server-allowedhosts
See: vitejs/vite#19325