You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/client.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -183,16 +183,24 @@ With caching on, `query` / `static` function responses are memoized per argument
183
183
184
184
## Discovery (`__connection.json`)
185
185
186
-
Devframe writes a JSON descriptor at `<base>/__connection.json` so the client knows where to connect:
186
+
Devframe writes a JSON descriptor at `<base>/__connection.json` so the client knows where to connect. The dev server shares one port for HTTP and the WebSocket — the socket is bound to a route (`<base>__devframe_ws`) next to the meta file — and advertises it as a relative path:
187
187
188
188
```json
189
189
{
190
190
"backend": "websocket",
191
-
"websocket": "ws://localhost:9999/__ws"
191
+
"websocket": { "path": "__devframe_ws" }
192
192
}
193
193
```
194
194
195
-
or for static mode:
195
+
The client resolves that path against the origin it loaded from, swapping `http`→`ws` / `https`→`wss`. It never trusts a host or port baked into the descriptor, so the connection follows the page through a reverse proxy that rewrites the domain, port, or subpath.
196
+
197
+
The `websocket` field also accepts:
198
+
199
+
- A `number` — a port on the page's hostname (`ws(s)://<host>:<port>`).
200
+
- A full `ws://`/`wss://` URL string — used verbatim for a fixed cross-origin endpoint.
201
+
-`{ port }` / `{ host }` — a cross-origin endpoint (e.g. a side-car server on its own port), rooted at that host/port rather than the page origin.
Copy file name to clipboardExpand all lines: docs/helpers/vite-bridge.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,9 @@ export default defineConfig({
21
21
## Modes
22
22
23
23
-**Static mount** (default) — mounts `def.cli.distDir` at `options.base` (`/__<id>/` by default). No RPC server. Useful when you only need the SPA bundle served from a known path.
24
-
-**Bridge mode** (`devMiddleware: true | {…}`) — skips the static mount; the host app owns the SPA. Devframe spawns a separate RPC + WS server and registers Vite middleware at `<base>__connection.json` so the host-served SPA can discover the WS endpoint.
24
+
-**Bridge mode** (`devMiddleware: true | {…}`) — skips the static mount; the host app owns the SPA. Devframe spawns a separate RPC + WS server and registers Vite middleware at `<base>__connection.json` so the host-served SPA can discover the WS endpoint. The side-car listens on its own port, so the descriptor carries that port alongside the `/__devframe_ws` route.
25
+
26
+
To mount the RPC socket onto the Vite server's own port instead of a side-car — so it shares the origin with the app and rides through a proxy — pass an existing HTTP server and a route to [`startHttpAndWs`](/adapters/dev) via its `server` and `path` options. Devframe routes only that upgrade path and leaves the rest (Vite's HMR socket included) untouched.
0 commit comments