54
|------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------|
55
| `host` | `"localhost"` | Socket connection to frontend should use this host. |
56
| `isAppActive` | | (Optional) function that returns true/false, telling DevTools when it's ready to connect to React. |
57
+| `path` | `""` | Path appended to the WebSocket URI (e.g. `"/__react_devtools__/"`). Useful when proxying through a reverse proxy on a subpath. A leading `/` is added automatically if missing. |
58
| `port` | `8097` | Socket connection to frontend should use this port. |
59
| `resolveRNStyle` | | (Optional) function that accepts a key (number) and returns a style (object); used by React Native. |
60
| `retryConnectionDelay` | `200` | Delay (ms) to wait between retrying a failed Websocket connection |
142
}
143
```
144
144
-#### `startServer(port?: number, host?: string, httpsOptions?: Object, loggerOptions?: Object)`
145
+#### `startServer(port?, host?, httpsOptions?, loggerOptions?, path?, clientOptions?)`
146
Start a socket server (used to communicate between backend and frontend) and renders the DevTools UI.
147
148
This method accepts the following parameters:
149
| Name | Default | Description |
150
|---|---|---|
150
-| `port` | `8097` | Socket connection to backend should use this port. |
151
-| `host` | `"localhost"` | Socket connection to backend should use this host. |
151
+| `port` | `8097` | Port the local server listens on. |
152
+| `host` | `"localhost"` | Host the local server binds to. |
153
| `httpsOptions` | | _Optional_ object defining `key` and `cert` strings. |
154
| `loggerOptions` | | _Optional_ object defining a `surface` string (to be included with DevTools logging events). |
155
+| `path` | | _Optional_ path to append to the WebSocket URI served to connecting clients (e.g. `"/__react_devtools__/"`). Also set via the `REACT_DEVTOOLS_PATH` env var in the Electron app. |
156
+| `clientOptions` | | _Optional_ object with client-facing overrides (see below). |
157
+
158
+##### `clientOptions`
159
+
160
+When connecting through a reverse proxy, the client may need to connect to a different host, port, or protocol than the local server. Use `clientOptions` to override what appears in the `connectToDevTools()` script served to clients. Any field not set falls back to the corresponding server value.
161
+
162
+| Field | Default | Description |
163
+|---|---|---|
164
+| `host` | server `host` | Host the client connects to. |
165
+| `port` | server `port` | Port the client connects to. |
166
+| `useHttps` | server `useHttps` | Whether the client should use `wss://`. |
167
+
168
+These can also be set via environment variables in the Electron app:
169
+
170
+| Env Var | Description |
171
+|---|---|
172
+| `REACT_DEVTOOLS_CLIENT_HOST` | Overrides the host in the served client script. |
173
+| `REACT_DEVTOOLS_CLIENT_PORT` | Overrides the port in the served client script. |
174
+| `REACT_DEVTOOLS_CLIENT_USE_HTTPS` | Set to `"true"` to make the served client script use `wss://`. |
175
+
176
+##### Reverse proxy example
177
+
178
+Run DevTools locally on the default port, but tell clients to connect through a remote proxy:
179
+```sh
180
+REACT_DEVTOOLS_CLIENT_HOST=remote.example.com \
181
+REACT_DEVTOOLS_CLIENT_PORT=443 \
182
+REACT_DEVTOOLS_CLIENT_USE_HTTPS=true \
183
+REACT_DEVTOOLS_PATH=/__react_devtools__/ \
184
+react-devtools
185
+```
186
+The server listens on `localhost:8097`. The served script tells clients:
187
+```js
188
+connectToDevTools({host: 'remote.example.com', port: 443, useHttps: true, path: '/__react_devtools__/'})
189
+```
190
191
# Development
192