Open
Conversation
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.
PR Title
docs: add remote backend proxy pattern for hybrid dev environmentsDescription
This PR addresses #41406 by introducing a standard pattern for developing frontends locally while connecting to a remote backend (API/DB).
The current Preview MCP documentation assumes a unified local stack. However, developers often face resource constraints (RAM/CPU) or utilize shared development servers, necessitating a bridge between the local Vite dev server and a remote gateway.
Changes
dev-proxy.mjs: A lightweight, zero-dependency Node.js reverse proxy usingnode:http.dev-start.sh: A cross-platform shell wrapper to orchestrate the lifecycle of both the proxy and Vite.family: 4to prevent connection hangs.waitinstead ofwait -n(which requires Bash 4+).Architecture
The pattern implements the following flow:
Browser→Vite (5173)→dev-proxy (5174)→Remote Gateway (8080)Technical Implementation Details
The Proxy (
dev-proxy.mjs)OPTIONSpreflight requests and addsAccess-Control-Allow-Originheaders.family: 4option inhttp.requestto bypass known DNS resolution issues in Vite 7/Node 24 environments.The Orchestrator (
dev-start.sh)trapmechanism to ensure that stopping the script (Ctrl+C) kills both the proxy and Vite processes simultaneously, preventing "ghost" processes from occupying ports.GATEWAY_HOSTenvironment variable.How to Test
dev-proxy.mjsanddev-start.shin thescripts/directory.export GATEWAY_HOST="your.remote.ip"../scripts/dev-start.sh.Checklist
node:http)