infinicode 2.8.39 → 2.8.41
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.
|
@@ -119,8 +119,13 @@ export class MeshServer {
|
|
|
119
119
|
res.end(text);
|
|
120
120
|
})
|
|
121
121
|
.catch(err => {
|
|
122
|
-
res.
|
|
123
|
-
|
|
122
|
+
if (!res.headersSent) {
|
|
123
|
+
res.writeHead(502, { 'content-type': 'application/json' });
|
|
124
|
+
res.end(JSON.stringify({ ok: false, error: `scheduler unreachable: ${err instanceof Error ? err.message : String(err)}` }));
|
|
125
|
+
}
|
|
126
|
+
else if (!res.writableEnded) {
|
|
127
|
+
res.end();
|
|
128
|
+
}
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
131
|
/** Proxy the scheduler's full Control Center and its same-origin assets. */
|
|
@@ -149,11 +154,16 @@ export class MeshServer {
|
|
|
149
154
|
responseHeaders['set-cookie'] = `robopark_auth=${encodeURIComponent(presented)}; Path=/; SameSite=Lax`;
|
|
150
155
|
}
|
|
151
156
|
res.writeHead(upstream.status, responseHeaders);
|
|
152
|
-
res.end(await upstream.arrayBuffer());
|
|
157
|
+
res.end(Buffer.from(await upstream.arrayBuffer()));
|
|
153
158
|
})
|
|
154
159
|
.catch(err => {
|
|
155
|
-
res.
|
|
156
|
-
|
|
160
|
+
if (!res.headersSent) {
|
|
161
|
+
res.writeHead(502, { 'content-type': 'text/plain; charset=utf-8' });
|
|
162
|
+
res.end(`scheduler unreachable: ${err instanceof Error ? err.message : String(err)}`);
|
|
163
|
+
}
|
|
164
|
+
else if (!res.writableEnded) {
|
|
165
|
+
res.end();
|
|
166
|
+
}
|
|
157
167
|
});
|
|
158
168
|
}
|
|
159
169
|
/** Protected local runtime controls for the RoboPark operator dashboard. */
|
|
@@ -252,13 +262,9 @@ export class MeshServer {
|
|
|
252
262
|
return;
|
|
253
263
|
}
|
|
254
264
|
const remote = req.socket.remoteAddress ?? 'unknown';
|
|
255
|
-
// The
|
|
256
|
-
//
|
|
265
|
+
// The mesh node serves the full Park-enabled RoboPark Control Center. Its
|
|
266
|
+
// product APIs remain proxied under /robopark/* to the scheduler.
|
|
257
267
|
if (req.method === 'GET' && (path === '/' || path === '/ui' || path === '/dashboard')) {
|
|
258
|
-
if (this.opts.schedulerUrl) {
|
|
259
|
-
this.proxySchedulerPath(req, res, '/');
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
268
|
if (!this.opts.dashboardHtml) {
|
|
263
269
|
res.writeHead(404).end('dashboard not enabled (start with --dashboard)');
|
|
264
270
|
return;
|
|
@@ -278,15 +284,16 @@ export class MeshServer {
|
|
|
278
284
|
res.writeHead(404).end('mesh dashboard not enabled (start with --dashboard)');
|
|
279
285
|
return;
|
|
280
286
|
}
|
|
281
|
-
res.writeHead(200, {
|
|
287
|
+
res.writeHead(200, {
|
|
288
|
+
'content-type': 'text/html; charset=utf-8',
|
|
289
|
+
'cache-control': 'no-store',
|
|
290
|
+
...(this.opts.token && this.presentedToken(req)
|
|
291
|
+
? { 'set-cookie': `robopark_auth=${encodeURIComponent(this.presentedToken(req))}; Path=/; SameSite=Lax` }
|
|
292
|
+
: {}),
|
|
293
|
+
});
|
|
282
294
|
res.end(this.opts.dashboardHtml);
|
|
283
295
|
return;
|
|
284
296
|
}
|
|
285
|
-
// Full scheduler dashboard requests are same-origin after the root proxy.
|
|
286
|
-
if (this.opts.schedulerUrl && (path.startsWith('/api/') || path.startsWith('/static/') || path.startsWith('/vendor/'))) {
|
|
287
|
-
this.proxySchedulerPath(req, res, path);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
297
|
// Static assets bundled with the dashboard (robot concept avatars, etc.).
|
|
291
298
|
if (req.method === 'GET' && path.startsWith('/static/')) {
|
|
292
299
|
const asset = loadStaticAsset(path.slice(8));
|
package/package.json
CHANGED