Spaces:
Runtime error
Runtime error
Update proxy.js
Browse files
proxy.js
CHANGED
|
@@ -30,15 +30,36 @@ const server = http.createServer((req, res) => {
|
|
| 30 |
const url = new URL(req.url || "/", "http://proxy.local");
|
| 31 |
|
| 32 |
if (url.pathname === "/__proxy_health") {
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
"
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
if (req.method === "GET" && url.pathname === "/") {
|
| 44 |
headers["accept-encoding"] = "identity";
|
|
|
|
| 30 |
const url = new URL(req.url || "/", "http://proxy.local");
|
| 31 |
|
| 32 |
if (url.pathname === "/__proxy_health") {
|
| 33 |
+
// Bootstrap OpenClaw Control UI with the gateway token.
|
| 34 |
+
if (req.method === "GET") {
|
| 35 |
+
const url = new URL(req.url, "http://localhost");
|
| 36 |
+
|
| 37 |
+
if (
|
| 38 |
+
(url.pathname === "/" || url.pathname === "/chat") &&
|
| 39 |
+
!url.searchParams.has("token")
|
| 40 |
+
) {
|
| 41 |
+
url.searchParams.set(
|
| 42 |
+
"token",
|
| 43 |
+
process.env.OPENCLAW_GATEWAY_TOKEN || ""
|
| 44 |
+
);
|
| 45 |
+
|
| 46 |
+
if (!process.env.OPENCLAW_GATEWAY_TOKEN) {
|
| 47 |
+
res.writeHead(500, {
|
| 48 |
+
"content-type": "text/plain",
|
| 49 |
+
"cache-control": "no-store"
|
| 50 |
+
});
|
| 51 |
+
res.end("OPENCLAW_GATEWAY_TOKEN is not configured");
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
res.writeHead(302, {
|
| 56 |
+
location: url.pathname + url.search,
|
| 57 |
+
"cache-control": "no-store"
|
| 58 |
+
});
|
| 59 |
+
res.end();
|
| 60 |
+
return;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
|
| 64 |
if (req.method === "GET" && url.pathname === "/") {
|
| 65 |
headers["accept-encoding"] = "identity";
|