Files
sencho/backend
SaelixCode 774190cbb8 fix(remote): strip cookie header and nodeId from WS/HTTP proxy to remote nodes
Two related auth/routing bugs broke Terminal logs, container stats, the
LogViewer SSE stream, and exec bash when a remote node was selected:

1. WebSocket proxy (upgrade handler) was forwarding the browser's
   `cookie` header to the remote Sencho instance.  The remote's
   `authMiddleware` evaluates `cookieToken || bearerToken`, so it
   picked the cookie first — signed with the *local* JWT secret — and
   returned 401 before even seeing the valid Bearer token.
   Fix: `delete req.headers['cookie']` before `wsProxyServer.ws()`,
   matching the `proxyReq.removeHeader('cookie')` already present in
   the HTTP proxy.

2. WebSocket proxy was also forwarding `?nodeId=<gatewayId>` in the
   URL.  The remote's `nodeContextMiddleware` rejected it with 404
   ("Node X not found") because gateway node IDs don't exist on the
   remote instance.
   Fix: strip `nodeId` from `req.url` before proxying, so the remote
   defaults cleanly to its own local node.

3. HTTP proxy (`remoteNodeProxy`) was forwarding `?nodeId=<gatewayId>`
   in `proxyReq.path` to the remote.  Affected EventSource endpoints
   like `/api/containers/:id/logs?nodeId=9` that pass nodeId as a
   query param rather than the `x-node-id` header.
   Fix: strip `nodeId` from `proxyReq.path` in `onProxyReq`.
2026-03-20 00:33:48 -04:00
..