Skip to content

Conversation

@ctate
Copy link

@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 Jan 26, 2026
@bluwy
Copy link
Member

bluwy commented Jan 28, 2026

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

@ctate
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants