Spaces:
Sleeping
Sleeping
Upload scripts/a2a-proxy.cjs with huggingface_hub
Browse files- scripts/a2a-proxy.cjs +26 -18
scripts/a2a-proxy.cjs
CHANGED
|
@@ -305,24 +305,32 @@ const server = http.createServer((req, res) => {
|
|
| 305 |
return;
|
| 306 |
}
|
| 307 |
|
| 308 |
-
//
|
| 309 |
-
if (
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
}
|
| 327 |
|
| 328 |
// Everything else → OpenClaw
|
|
|
|
| 305 |
return;
|
| 306 |
}
|
| 307 |
|
| 308 |
+
// Office frontend (only served if OFFICE_MODE=1, e.g. on dedicated office spaces)
|
| 309 |
+
if (process.env.OFFICE_MODE === '1') {
|
| 310 |
+
// Serve index.html at /
|
| 311 |
+
if (pathname === '/' && req.method === 'GET') {
|
| 312 |
+
const indexPath = path.join(FRONTEND_DIR, 'index.html');
|
| 313 |
+
return serveStaticFile(res, indexPath);
|
| 314 |
+
}
|
| 315 |
+
// Serve static assets at /static/*
|
| 316 |
+
if (pathname.startsWith('/static/')) {
|
| 317 |
+
const assetPath = path.join(FRONTEND_DIR, pathname.slice('/static/'.length).split('?')[0]);
|
| 318 |
+
return serveStaticFile(res, assetPath);
|
| 319 |
+
}
|
| 320 |
+
// Admin panel → proxy to OpenClaw UI
|
| 321 |
+
if (pathname === '/admin' || pathname === '/admin/') {
|
| 322 |
+
const token = process.env.GATEWAY_TOKEN || '';
|
| 323 |
+
req.url = token ? `/?token=${token}` : '/';
|
| 324 |
+
return proxyRequest(req, res, OPENCLAW_PORT);
|
| 325 |
+
}
|
| 326 |
+
} else {
|
| 327 |
+
// Default mode: / goes directly to OpenClaw with token
|
| 328 |
+
if (pathname === '/' && req.method === 'GET' && !url.parse(req.url, true).query.token) {
|
| 329 |
+
const token = process.env.GATEWAY_TOKEN || '';
|
| 330 |
+
if (token) {
|
| 331 |
+
req.url = `/?token=${token}`;
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
}
|
| 335 |
|
| 336 |
// Everything else → OpenClaw
|