tao-shen commited on
Commit
8bd6f75
·
verified ·
1 Parent(s): b0a12d6

Upload scripts/a2a-proxy.cjs with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/a2a-proxy.cjs +9 -5
scripts/a2a-proxy.cjs CHANGED
@@ -324,11 +324,15 @@ const server = http.createServer((req, res) => {
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
  }
 
324
  return proxyRequest(req, res, OPENCLAW_PORT);
325
  }
326
  } else {
327
+ // Default mode: redirect / to /?token=xxx so browser URL has the token
328
+ if (pathname === '/' && req.method === 'GET' && !req.headers.upgrade) {
329
+ const query = url.parse(req.url, true).query;
330
+ if (!query.token) {
331
+ const token = process.env.GATEWAY_TOKEN || '';
332
+ if (token) {
333
+ res.writeHead(302, { Location: `/?token=${token}` });
334
+ return res.end();
335
+ }
336
  }
337
  }
338
  }