fix webui white screen: persist token via cookie for asset/api auth

This commit is contained in:
DBT
2026-02-25 13:24:48 +00:00
parent deaeac8cba
commit 94325de477

View File

@@ -133,6 +133,16 @@ func (s *RegistryServer) handleWebUI(w http.ResponseWriter, r *http.Request) {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
if s.token != "" {
http.SetCookie(w, &http.Cookie{
Name: "clawgo_webui_token",
Value: s.token,
Path: "/",
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
MaxAge: 86400,
})
}
if s.tryServeWebUIDist(w, r, "/webui/index.html") {
return
}
@@ -372,6 +382,9 @@ func (s *RegistryServer) checkAuth(r *http.Request) bool {
if strings.TrimSpace(r.URL.Query().Get("token")) == s.token {
return true
}
if c, err := r.Cookie("clawgo_webui_token"); err == nil && strings.TrimSpace(c.Value) == s.token {
return true
}
return false
}