akashyadav758 Claude Opus 4.7 (1M context) commited on
Commit
6d42e1f
·
1 Parent(s): 23bf5e5

Open monitor UI on private Space (owner was locked out of own live view)

Browse files

Gating / and /api/* on the API key locked the Space owner out: a private HF
Space serves its subdomain behind HF auth, and the browser can't attach ?key=
there, so the UI returned 401. The Space being private already restricts who
can reach it to the owner, so the UI (/, /api/*, /chrome.log) is open again.
Only the programmatic AI gateway (/gpt /gemini /flow) and /logs stay key-gated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. monitor/main.go +16 -19
monitor/main.go CHANGED
@@ -622,33 +622,30 @@ func main() {
622
  }
623
  }()
624
 
 
 
 
 
 
625
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
626
  if r.URL.Path != "/" {
627
  http.NotFound(w, r)
628
  return
629
  }
630
- if !authOK(w, r) {
631
- return
632
- }
633
- // If the key arrived via ?key=, persist it as a cookie so the in-page
634
- // /api/* fetches (same origin) stay authorized without re-passing it.
635
- if k := r.URL.Query().Get("key"); k != "" && k == apiKey {
636
- http.SetCookie(w, &http.Cookie{Name: "apikey", Value: k, Path: "/", HttpOnly: true, SameSite: http.SameSiteStrictMode})
637
- }
638
  w.Header().Set("Content-Type", "text/html; charset=utf-8")
639
  w.Write(indexHTML)
640
  })
641
- http.HandleFunc("/api/tabs", gate(tabsHandler))
642
- http.HandleFunc("/api/screen", gate(screenHandler))
643
- http.HandleFunc("/api/input", gate(inputHandler))
644
- http.HandleFunc("/api/navigate", gate(navigateHandler))
645
- http.HandleFunc("/api/reload", gate(reloadHandler))
646
- http.HandleFunc("/api/back", gate(historyHandler(-1)))
647
- http.HandleFunc("/api/forward", gate(historyHandler(+1)))
648
- http.HandleFunc("/api/newtab", gate(newtabHandler))
649
- http.HandleFunc("/api/closetab", gate(closetabHandler))
650
- http.HandleFunc("/api/stats", gate(statsHandler))
651
- http.HandleFunc("/chrome.log", gate(chromeLogHandler))
652
  http.HandleFunc("/logs/", backendLogHandler)
653
 
654
  // API gateway → the three backend servers on localhost (API-key gated).
 
622
  }
623
  }()
624
 
625
+ // The monitor UI (/, /api/*, /chrome.log) is open — the Space is private, so
626
+ // HuggingFace's own auth already gates who can reach it (the owner). The browser
627
+ // can't attach ?key= when HF serves the private subdomain, so requiring our key
628
+ // here locks the owner out of their own live view. Only the AI gateway
629
+ // (/gpt /gemini /flow) and /logs stay API-key-gated for external programmatic use.
630
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
631
  if r.URL.Path != "/" {
632
  http.NotFound(w, r)
633
  return
634
  }
 
 
 
 
 
 
 
 
635
  w.Header().Set("Content-Type", "text/html; charset=utf-8")
636
  w.Write(indexHTML)
637
  })
638
+ http.HandleFunc("/api/tabs", tabsHandler)
639
+ http.HandleFunc("/api/screen", screenHandler)
640
+ http.HandleFunc("/api/input", inputHandler)
641
+ http.HandleFunc("/api/navigate", navigateHandler)
642
+ http.HandleFunc("/api/reload", reloadHandler)
643
+ http.HandleFunc("/api/back", historyHandler(-1))
644
+ http.HandleFunc("/api/forward", historyHandler(+1))
645
+ http.HandleFunc("/api/newtab", newtabHandler)
646
+ http.HandleFunc("/api/closetab", closetabHandler)
647
+ http.HandleFunc("/api/stats", statsHandler)
648
+ http.HandleFunc("/chrome.log", chromeLogHandler)
649
  http.HandleFunc("/logs/", backendLogHandler)
650
 
651
  // API gateway → the three backend servers on localhost (API-key gated).