tao-shen commited on
Commit
b0a12d6
·
verified ·
1 Parent(s): 0fa48ff

Upload scripts/a2a-proxy.cjs with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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
- // Serve index.html at /
309
- if (pathname === '/' && req.method === 'GET') {
310
- const indexPath = path.join(FRONTEND_DIR, 'index.html');
311
- return serveStaticFile(res, indexPath);
312
- }
313
-
314
- // Serve static assets at /static/*
315
- if (pathname.startsWith('/static/')) {
316
- const assetPath = path.join(FRONTEND_DIR, pathname.slice('/static/'.length).split('?')[0]);
317
- return serveStaticFile(res, assetPath);
318
- }
319
-
320
- // Admin panel → proxy to OpenClaw UI directly
321
- if (pathname === '/admin' || pathname === '/admin/') {
322
- const token = process.env.GATEWAY_TOKEN || '';
323
- // Rewrite to OpenClaw root with token
324
- req.url = token ? `/?token=${token}` : '/';
325
- return proxyRequest(req, res, OPENCLAW_PORT);
 
 
 
 
 
 
 
 
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