xkailashhh commited on
Commit
f8f45f0
·
verified ·
1 Parent(s): f9a5ea9

Update proxy.js

Browse files
Files changed (1) hide show
  1. proxy.js +30 -9
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
- res.writeHead(200, {
34
- "content-type": "application/json",
35
- "cache-control": "no-store"
36
- });
37
- res.end(JSON.stringify({ status: "ok", service: "proxy" }));
38
- return;
39
- }
40
-
41
- const headers = proxyHeaders(req);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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";