Allow custom domains in Vite's allowedHosts#51395
Merged
Conversation
ravicious
approved these changes
Jan 23, 2025
ravicious
reviewed
Jan 23, 2025
| } | ||
|
|
||
| return []; | ||
| } |
Member
There was a problem hiding this comment.
Could be something like this to allow target and VITE_HOST at the same time because why not.
function resolveAllowedHost(target: string) {
const allowedHosts = [];
if (process.env.VITE_HOST) {
allowedHosts.push(process.env.VITE_HOST);
}
if (target !== DEFAULT_PROXY_TARGET) {
const { hostname } = new URL(`http://${target}`);
allowedHosts.push(hostname);
}
return allowedHosts;
}I guess it all comes down to which domains you have in the cert that Vite uses? But I noticed that the docs say "When using HTTPS, this check is skipped" and that is true, but the thing that falls apart without allowedHosts is websockets (and thus HMR).
Member
Author
There was a problem hiding this comment.
Yeah I think if your cert accepts localhost it'll still work without setting allowedHosts - but first Vite will try the hostname you're using, so there will be one error in the console always, but HMR would still work
I think your suggestion is good, I'll add it
23307c5 to
6f857e3
Compare
6f857e3 to
0e8e356
Compare
strideynet
approved these changes
Jan 23, 2025
carloscastrojumo
pushed a commit
to carloscastrojumo/teleport
that referenced
this pull request
Feb 19, 2025
* Allow custom domains in Vite's allowedHosts * Allow both VITE_HOST and the target to be allowedHosts
ravicious
pushed a commit
that referenced
this pull request
Feb 6, 2026
* Allow custom domains in Vite's allowedHosts * Allow both VITE_HOST and the target to be allowedHosts
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
* Bump the electron group across 1 directory with 4 updates * Bump the electron group across 1 directory with 4 updates Bumps the electron group with 4 updates in the / directory: [node-pty](https://github.com/microsoft/node-pty), [electron](https://github.com/electron/electron), [electron-updater](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-updater) and [electron-vite](https://github.com/alex8088/electron-vite). Updates `node-pty` from 1.1.0-beta35 to 1.1.0 - [Release notes](https://github.com/microsoft/node-pty/releases) - [Commits](microsoft/node-pty@v1.1.0-beta35...v1.1.0) Updates `electron` from 39.2.2 to 40.1.0 - [Release notes](https://github.com/electron/electron/releases) - [Commits](electron/electron@v39.2.2...v40.1.0) Updates `electron-updater` from 6.7.0 to 6.7.3 - [Release notes](https://github.com/electron-userland/electron-builder/releases) - [Changelog](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/CHANGELOG.md) - [Commits](https://github.com/electron-userland/electron-builder/commits/electron-updater@6.7.3/packages/electron-updater) Updates `electron-vite` from 4.0.1 to 5.0.0 - [Release notes](https://github.com/alex8088/electron-vite/releases) - [Changelog](https://github.com/alex8088/electron-vite/blob/master/CHANGELOG.md) - [Commits](alex8088/electron-vite@v4.0.1...v5.0.0) --- updated-dependencies: - dependency-name: node-pty dependency-version: 1.1.0 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: electron - dependency-name: electron dependency-version: 40.1.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: electron - dependency-name: electron-updater dependency-version: 6.7.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: electron - dependency-name: electron-vite dependency-version: 5.0.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: electron ... Signed-off-by: dependabot[bot] <support@github.com> * Revert unnecessary updates * Bump Node.js to 24 * Add node-pty prebuilds to `x64ArchFiles` * Update node-pty to 1.2.0-beta.10 * Add fix for Wayland --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Grzegorz Zdunek <grzegorz.zdunek@goteleport.com> Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com> * Update Vite & related packages to latest * Upgrade vite to 6.0.11 (#51356) * Allow custom domains in Vite's allowedHosts (#51395) * Allow custom domains in Vite's allowedHosts * Allow both VITE_HOST and the target to be allowedHosts * Use exact dep versions as v18 I think it'd have been enough to update `@vitejs/plugin-react-swc` to 3.9.0, but just to be sure I changed the versions to match v18. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Grzegorz Zdunek <grzegorz.zdunek@goteleport.com> Co-authored-by: Ryan Clark <ryan.clark@goteleport.com> Co-authored-by: Michael <michael.myers@goteleport.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#51356 introduces the change of setting
allowedHostto whatever the domain of the proxy target is, if it isn't localhost. That doesn't really work for my setup, and possibly others, as I use a different domain than localhost and the proxy target. This allows the option of setting aVITE_HOSTenvironment variable (I followed the same convention in TAG), so we're not allowing all hosts.