feat(plugin-vite): support custom server host in renderer dev server URL - #4363
Merged
Conversation
Previously, the Vite plugin hardcoded the development server URL exposed to the main process to http://localhost:<port>, which prevented custom host configurations (network debugging across devices, Docker container development, remote development setups). The URL now respects a string `server.host` from the resolved Vite config. Wildcard hosts (`true`, `0.0.0.0`, `::`) fall back to `localhost`, since the main process runs on the same machine and wildcard addresses are not reliably loadable in Chromium, and IPv6 literals are bracketed to form valid URLs. Ported from #4030 onto the `next` branch, with wildcard/IPv6 normalization and test coverage added. Co-authored-by: chenjiahao <chenjiahao@jd.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012hunyjnAGo97Vz7v2XgVJt
georgexu99
approved these changes
Sep 2, 2026
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.
Summarize your changes:
Ports #4030 by @ChenJiaH onto the
nextbranch. Credit for the original change goes to @ChenJiaH (also credited viaCo-authored-byon the commit).Previously, the Vite plugin hardcoded the development server URL exposed to the main process (via the
<NAME>_VITE_DEV_SERVER_URLdefine constant) tohttp://localhost:<port>. This prevented developers from using custom host addresses for the Vite dev server, which is useful for:The URL now respects a string
server.hostfrom the resolved Vite config. On top of the original PR, this port adds:true,'0.0.0.0','::') are normalized tolocalhost, since the main process runs on the same machine and wildcard addresses are not reliably loadable in Chromium (http://:::5173is not even a valid URL).vite.base.config.spec.tsfor both a custom string host and the wildcard fallback.🤖 Generated with Claude Code
https://claude.ai/code/session_012hunyjnAGo97Vz7v2XgVJt
Generated by Claude Code