-
Notifications
You must be signed in to change notification settings - Fork 0
[DevTools] Enable support for the React DevTools Client to connect to different host/port/path #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,12 +158,19 @@ | |
| <script> | ||
| // window.api is defined in preload.js | ||
| const {electron, readEnv, ip, getDevTools} = window.api; | ||
| const {options, useHttps, host, protocol, port} = readEnv(); | ||
| const {options, useHttps, host, protocol, port, path, clientHost, clientPort, clientUseHttps} = readEnv(); | ||
|
|
||
| const localIp = ip.address(); | ||
| const defaultPort = (port === 443 && useHttps) || (port === 80 && !useHttps); | ||
| const server = defaultPort ? `${protocol}://${host}` : `${protocol}://${host}:${port}`; | ||
| const serverIp = defaultPort ? `${protocol}://${localIp}` : `${protocol}://${localIp}:${port}`; | ||
|
|
||
| // Effective values for display URLs: client overrides take precedence over server values. | ||
| const effectiveHost = clientHost != null ? clientHost : host; | ||
| const effectivePort = clientPort != null ? clientPort : port; | ||
| const effectiveUseHttps = clientUseHttps != null ? clientUseHttps : useHttps; | ||
| const effectiveProtocol = effectiveUseHttps ? 'https' : 'http'; | ||
| const defaultPort = (effectivePort === 443 && effectiveUseHttps) || (effectivePort === 80 && !effectiveUseHttps); | ||
| const pathStr = path != null ? path : ''; | ||
| const server = defaultPort ? `${effectiveProtocol}://${effectiveHost}${pathStr}` : `${effectiveProtocol}://${effectiveHost}:${effectivePort}${pathStr}`; | ||
| const serverIp = defaultPort ? `${effectiveProtocol}://${localIp}${pathStr}` : `${effectiveProtocol}://${localIp}:${effectivePort}${pathStr}`; | ||
|
Comment on lines
+166
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "By IP" display URL is misleading with client overrides When client overrides are set (e.g., Consider either falling back to the server's own port/protocol for the IP-based URL (since that represents the local server), or hiding the "by IP" suggestion entirely when Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/react-devtools/app.html
Line: 166-173
Comment:
**"By IP" display URL is misleading with client overrides**
When client overrides are set (e.g., `REACT_DEVTOOLS_CLIENT_HOST=remote.example.com`, `REACT_DEVTOOLS_CLIENT_PORT=443`, `REACT_DEVTOOLS_CLIENT_USE_HTTPS=true`), `serverIp` becomes something like `https://192.168.1.5:443/__react_devtools__/`. This mixes the local IP with the remote proxy's protocol/port, producing a URL that won't work.
Consider either falling back to the server's own port/protocol for the IP-based URL (since that represents the local server), or hiding the "by IP" suggestion entirely when `clientHost` is set.
How can I resolve this? If you propose a fix, please make it concise. |
||
| const $ = document.querySelector.bind(document); | ||
|
|
||
| let timeoutID; | ||
|
|
@@ -234,7 +241,7 @@ | |
| element.innerText = status; | ||
| } | ||
| }) | ||
| .startServer(port, host, options); | ||
| .startServer(port, host, options, undefined, path, {host: clientHost, port: clientPort, useHttps: clientUseHttps}); | ||
| </script> | ||
| </body> | ||
| </html> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing leading
/normalization forpathbackend.js:112normalizes thepathby prepending/if it's missing, but this display URL construction does not. If a user setsREACT_DEVTOOLS_PATH=__react_devtools__/(without a leading/), the display URL becomeshttp://localhost:8097__react_devtools__/— a broken URL with no path separator.Consider normalizing
pathStrthe same waybackend.jsdoes:Prompt To Fix With AI