Spaces:
Sleeping
Sleeping
Upload scripts/a2a-proxy.cjs with huggingface_hub
Browse files- 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: /
|
| 328 |
-
if (pathname === '/' && req.method === 'GET' && !
|
| 329 |
-
const
|
| 330 |
-
if (token) {
|
| 331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
}
|