agentgui 1.0.966 → 1.0.967
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/site/app/js/backend.js +11 -3
package/package.json
CHANGED
package/site/app/js/backend.js
CHANGED
|
@@ -200,20 +200,26 @@ function scheduleReconnect() {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
function wsUrl(base) {
|
|
203
|
-
let proto, host;
|
|
203
|
+
let proto, host, prefix = '';
|
|
204
204
|
if (base) {
|
|
205
205
|
try {
|
|
206
206
|
const u = new URL(base);
|
|
207
207
|
proto = u.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
208
208
|
host = u.host;
|
|
209
|
+
// A custom backend URL may carry a routing path prefix (e.g. https://host/gm).
|
|
210
|
+
prefix = u.pathname.replace(/\/+$/, '');
|
|
209
211
|
} catch {}
|
|
210
212
|
}
|
|
211
213
|
if (!host) {
|
|
212
214
|
proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
213
215
|
host = location.host;
|
|
216
|
+
// Same-origin: honour the server-injected router prefix so the socket is
|
|
217
|
+
// routed correctly behind a path-routing proxy (e.g. nginx /gm/ -> 9897).
|
|
218
|
+
const bu = (typeof window !== 'undefined' && window.__BASE_URL) || '';
|
|
219
|
+
prefix = String(bu).replace(/\/+$/, '');
|
|
214
220
|
}
|
|
215
221
|
const tok = authToken();
|
|
216
|
-
return proto + '//' + host + SYNC_PATH + (tok ? '?token=' + encodeURIComponent(tok) : '');
|
|
222
|
+
return proto + '//' + host + prefix + SYNC_PATH + (tok ? '?token=' + encodeURIComponent(tok) : '');
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
function ensureWs(base) {
|
|
@@ -231,7 +237,9 @@ function ensureWs(base) {
|
|
|
231
237
|
}
|
|
232
238
|
resolve(_ws);
|
|
233
239
|
});
|
|
234
|
-
|
|
240
|
+
// The error Event has no .message; reject with a real Error so callers log
|
|
241
|
+
// a usable reason instead of "undefined" (e.g. "agents fetch failed: ...").
|
|
242
|
+
_ws.addEventListener('error', () => { emitStatus('error'); reject(new Error('WebSocket connection failed')); });
|
|
235
243
|
_ws.addEventListener('close', () => {
|
|
236
244
|
emitStatus('closed');
|
|
237
245
|
for (const [, p] of _pending) p.reject(new Error('ws closed'));
|