Skip to content

feat(server): support multiple hosts in __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS#21501

Open
ctate wants to merge 1 commit intovitejs:mainfrom
ctate:ctate/allow-multi-hosts
Open

feat(server): support multiple hosts in __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS#21501
ctate wants to merge 1 commit intovitejs:mainfrom
ctate:ctate/allow-multi-hosts

Conversation

@ctate
Copy link
Copy Markdown

@ctate ctate commented Jan 26, 2026

Allows __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS environment variable to accept multiple comma-separated hosts instead of just a single host.

# Before: single host only
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=example.com

# After: multiple hosts supported
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=example.com,test.com,dev.example.org
  • Splits the environment variable value by commas
  • Trims whitespace from each host
  • Filters out empty entries
  • Fully backwards compatible with single host values
  • Updated documentation (docs/config/server-options.md)
  • Included tests (6 new unit tests in config.spec.ts)

@ctate ctate changed the title support multiple hosts in __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS feat(server): support multiple hosts in __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS Jan 26, 2026
@bluwy
Copy link
Copy Markdown
Member

bluwy commented Jan 28, 2026

The change looks good to me. Can you share a bit of your usecase here?

@ctate
Copy link
Copy Markdown
Author

ctate commented Jan 28, 2026

@bluwy Thanks for reviewing!

The use case is cloud-based development environments that can generate multiple hostnames for a single dev session. These platforms sometimes rotate or assign multiple preview URLs that all need to be allowed.

With the previous implementation only supporting a single host, devs would hit the "This host is not allowed" error and have to manually edit vite.config.js. This isn't ideal because those environment-specific changes could accidentally get committed and pushed to the repo.

By parsing the env var as comma-separated values, cloud IDEs can transparently configure all their hosts via the environment - no config file changes needed, nothing to accidentally commit.

@bluwy bluwy added this to Team Board Mar 6, 2026
@github-project-automation github-project-automation Bot moved this to Discussing in Team Board Mar 6, 2026
@bluwy
Copy link
Copy Markdown
Member

bluwy commented Mar 6, 2026

I just realized a similar PR was opened before: #19746. The discussion there was to have proper comma parsing, though for me I'm not sure we need it for now.

@bluwy bluwy added this to the 8.1 milestone Mar 9, 2026
@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 18, 2026
@sapphi-red sapphi-red moved this from Discussing to Approved in Team Board Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

3 participants